當前位置:首頁 » 安卓系統 » android介紹頁

android介紹頁

發布時間: 2022-06-28 21:22:33

㈠ Android如何設置歡迎頁,然後隔幾秒進入主頁

你可以設置一個activity,然後啟動定時任務,時間到了就跳轉到主頁,並且finish()掉當前頁面。
也可以在主頁的activity裡面做,開始設置setContentView為歡迎頁,定時任務,時間到了setContentView為主頁,這樣還可以在此過程中做一些初始化工作

㈡ 安卓開源的android-FlipView,了解的請幫忙

1.ActionBarSherlock

ActionBarSherlock應該算得上是GitHub上最火的Android開源項目了,它是一個獨立的庫,通過一個API和主題,開發者就可以很方便地使用所有版本的Android動作欄的設計模式。

對於Android
4.0及更高版本,ActionBarSherlock可以自動使用本地ActionBar實現,而對於之前沒有ActionBar功能的版本,基於Ice
Cream
Sandwich的自定義動作欄實現將自動圍繞布局。能夠讓開發者輕松開發一款帶動作欄(Action
bar)的應用,並且適用於Android 2.x及其以上所有版本。

2.facebook-android-sdk

Facebook SDK for Android是一個開源庫,允許開發者將Facebook集成到所開發的Android應用中。

3.SlidingMenu(SlidingMenu
Demos)

SlidingMenu是一個開源的Android庫,能夠讓開發者輕松開發一款應用,實現類似於Google+、Youtube和Facebook應用中非常流行的滑動式菜單。

使用SlidingMenu的Android應用:

Foursquare
Rdio
Plume
VLC for Android
ESPN ScoreCenter
MLS MatchDay
9GAG
Wunderlist 2
The Verge
MTG Familiar
Mantano Reader
Falcon Pro (BETA)
MW3 Barracks
4. cocos2d-x

在移動開發領域,將Cocos2D-X用於主流iOS/Android游戲開發的公司、開發團隊多不勝數。cocos2d-x是一個開源的支持多平台的2D游戲框架,使用C++開發,基於cocos2d-iphone,在MIT許可證下發布。主分支在GitHub上使用OpenGL
ES 2.0渲染,而舊版gles11分支則使用OpenGL ES 1.1渲染。

支持iOS、Android、Windows Phone
8、Bada、BlackBerry、Marmalade、Windows、Linux等多個平台。支持C++、Lua、javaScript編程語言。

5. android
GitHub Android App是GitHub開源的Android客戶端,支持Issues、Gists,並集成了新聞Feed,能夠讓你及時跟進組織及關注的開發者、庫等。同時,該應用還提供了一個用戶快速訪問你所創建、監控及發布issue的面板,可查看並將問題加入到收藏夾,可對標簽、里程碑和任務進行過濾配置。

android資源庫包含了GitHub Android App的所有源代碼。

6.Android-ViewPagerIndicator

ViewPager指針項目,在使用ViewPager的時候能夠指示ViewPager所在的位置,就像Google
Play中切換的效果一樣,還能使用在應用初始化的介紹頁面。

兼容Android支持庫的ViewPager及ActionBarSherlock,最初是基於Patrik
Åkerfeldt的ViewFlow。

7. MonoGame

MonoGame是一個Microsoft XNA 4.x
Framework的開源跨平台實現。用於讓XNA開發者將他們在Xbox 360、Windows &
Windows Phone上開發的游戲移植到iOS、Android、Mac OS X、Linux及Windows 8
Metro上,目前,PlayStation Mobile & Raspberry PI的開發正在進行中。

8.Android-PullToRefresh

該項目用於為Android提供一個可重用的下拉刷新部件。它最初來源於Johan
Nilsson的庫(主要是圖形、字元串和動畫),但這些後來都已被取代。

9. android-async-http

android-async-http是Android上的一個非同步、基於回調的HTTP客戶端開發包,建立在Apache的HttpClient庫上。

10.Android-Universal-Image-Loader

Android上最讓人頭疼的莫過於從網路獲取圖片、顯示、回收,任何一個環節有問題都可能直接OOM,這個項目或許能幫到你。

Universal Image Loader for
Android的目的是為了實現非同步的網路圖片載入、緩存及顯示,支持多線程非同步載入。它最初來源於Fedor
Vlasov的項目,且自此之後,經過大規模的重構和改進。

11. GreenDroid

GreenDroid最初是由Cyril
Mottier發起,是一個Android的UI開發類庫,能夠讓UI開發更加簡便,並且在應用中始終保持一致。

12. Anki-Android

AnkiDroid是一個免費、開源的Android的快閃記憶體應用,可直接從Google
Play進行下載。

13.android-actionbar

Action
bar是一個標識應用程序和用戶位置的窗口功能,並且給用戶提供操作和導航模式。在大多數的情況下,當開發者需要突出展現用戶行為或在全局導航的activity中使用action
bar,因為action
bar能夠使應用程序給用戶提供一致的界面,且系統能夠很好地根據不同的屏幕配置來適應操作欄的外觀。

Action bar的主要目的:

提供一個用於識別應用程序的標示和用戶的位置的專用空間。
在不同的應用程序之間提供一致的導航和視覺體驗。
突出Activity的關鍵操作,並且在可預見的方法內給用戶提供快捷的訪問。
14.android-viewflow

android-viewflow是Android平台上的一個視圖切換的效果庫,ViewFlow相當於Android
UI部件提供水平滾動的ViewGroup,使用Adapter進行條目綁定。

15.android-mapviewballoons

當使用Android地圖外部庫(com.google.android.maps)時,android-mapviewballoons會提供一個簡單的方式來對地圖覆蓋進行標注,就是一個簡單的信息氣泡。

它由BalloonOverlayView組成,是一個代表顯示你的MapView及BalloonIt www.hbbz08.com emizedOverlay的氣泡的視圖,BalloonItemizedOverlay是ItemizedOverlay的一個抽象擴展。

16.PushSharp

一個向iOS(iPhone/iPad APNS)、Android(C2DM和GCM)、Windows
Phone和Windows 8設備發送推送通知的伺服器端庫。

17.androidannotations

Android Annotations是一個開源的框架,用於加速
Android應用的開發,可以讓你把重點放在功能的實現上,簡化了代碼,提升了可維護性。

18.HockeyKit

Hockey是一個iOS Ad-Hoc自動更新框架。蘋果App
Store中的所有App都可以使用它,它能夠顯著地提高Beta測試的整個過程,分為兩部分:伺服器和客戶端框架。伺服器組件需要所有腳本,但在沒有客戶端庫的情況下,也可以單獨工作。它提供一個Web介面,Beta測試者可以使用它來安裝最新的AdHoc配置文件,也可以直接在設備上通過Safari安裝最新的Beta版本。

只需在伺服器上安裝一次服務端,就可以處理包標識符不同的多個應用程序(有開發者強烈建議對Debug、AdHoc Beta和AppStore發布版使用不同的包標識符)。
默認當App啟動或喚醒時,客戶端會從伺服器檢測更新,用戶可以在設置對話框中進行修改:一天一次或手動檢查更新。
除了支持iOS,HokeyKit也支持Android平台, 不過Android版還處在Alpha階段,支持OTA及應用內更新。
為HockeyKit用戶提供伺服器託管服務。
19.android-menudrawer

Android上的菜單展示風格各異,其中用得最多且體驗最好的莫過於左右滑動來顯示隱藏的菜單,android-menudrawer是一個滑動式菜單實現,允許用戶在應用當中實現無縫導航。該項目具有多種菜單展示效果,其中最常見的就是通過屏幕邊緣拖動或點擊動作欄的「向上」按鈕顯示。

㈢ 手機淘寶頁面android的布局怎麼寫

使用viewpager+tablayout.下面是效果截圖,解決辦法來自於android學習手冊,android學習手冊包含9個章節,108個例子,源碼文檔隨便看,例子都是可交互,可運行,源碼採用android
studio目錄結構,高亮顯示代碼,文檔都採用文檔結構圖顯示,可以快速定位。360手機助手中下載。排到第三個。

㈣ android應用開發詳解頁碼是多少

您好,很高興為您解答:
Android應用開發詳解是一本Android應用開發書籍,既適合Android初學者,也適合具備了一定Android開發經驗但需要開發案例的高級讀者。
​該書分為三個部分,共18章,由淺入深地詳細介紹了Android的每個開發細節。 該書基礎翔實,實例豐富,案例真實。從基礎到案例覆蓋了Android應用開發的三大領域:基礎應用、網路應用和游戲應用。讀者所需要學習的,正是該書描述的。
書名:Android應用開發詳解
作者:郭宏志 編著
ISBN 978-7-121-10875-4
出版日期:2010年6月
開本:16開
頁碼:508 頁
轉載,僅供參考。
如果我的回答沒能幫助您,請繼續追問。

㈤ android怎麼從引導頁進入主頁

1 import android.app.Activity;
2 import android.content.Intent;
3 import android.content.SharedPreferences;
4 import android.content.SharedPreferences.Editor;
5 import android.os.Bundle;
6 import android.os.Handler;
7
8 /** 歡迎界面 */
9 public class WelcomeAct extends Activity {
10
11 private boolean isFirstIn = false;
12 private static final int TIME = 2000;
13 private static final int GO_HOME = 1000;
14 private static final int GO_GUIDE = 1001;
15
16 private Handler mHandler = new Handler() {
17 public void handleMessage(android.os.Message msg) {
18 switch (msg.what) {
19 // 跳入主界面
20 case GO_HOME:
21 goHome();
22 break;
23 // 跳入引導頁
24 case GO_GUIDE:
25 goGuide();
26 break;
27 }
28 };
29 };
30
31 @Override
32 protected void onCreate(Bundle savedInstanceState) {
33 super.onCreate(savedInstanceState);
34 setContentView(R.layout.welcome);
35 init();
36 }
37
38 private void init() {
39 SharedPreferences perPreferences = getSharedPreferences("jike",
40 MODE_PRIVATE);
41 isFirstIn = perPreferences.getBoolean("isFirstIn", true);
42 if (!isFirstIn) {
43 mHandler.sendEmptyMessageDelayed(GO_HOME, TIME);
44 } else {
45 mHandler.sendEmptyMessageDelayed(GO_GUIDE, TIME);
46 Editor editor = perPreferences.edit();
47 editor.putBoolean("isFirstIn", false);
48 editor.commit();
49 }
50 }
51
52 private void goHome() {
53 Intent i = new Intent(WelcomeAct.this, MainActivity.class);
54 startActivity(i);
55 finish();
56 }
57
58 private void goGuide() {
59 Intent i = new Intent(WelcomeAct.this, Guide.class);
60 startActivity(i);
61 finish();
62 }
63
64 }

1 import java.util.ArrayList;
2 import java.util.List;
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.os.Bundle;
6 import android.support.v4.view.ViewPager;
7 import android.support.v4.view.ViewPager.OnPageChangeListener;
8 import android.view.LayoutInflater;
9 import android.view.View;
10 import android.view.View.OnClickListener;
11 import android.widget.Button;
12 import android.widget.ImageView;
13
14 /** 引導頁 */
15 public class Guide extends Activity implements OnPageChangeListener {
16
17 private ViewPager vp;
18 private ViewPagerAdapter vpAdapter;
19 private List<View> views;
20 private ImageView[] dots;
21 private int[] ids = { R.id.iv1, R.id.iv2, R.id.iv3 };
22 private Button start_btn;
23
24 @Override
25 protected void onCreate(Bundle savedInstanceState) {
26 super.onCreate(savedInstanceState);
27 setContentView(R.layout.guide);
28 initViews();
29 initDots();
30 }
31
32 private void initViews() {
33 LayoutInflater inflater = LayoutInflater.from(this);
34
35 views = new ArrayList<View>();
36 views.add(inflater.inflate(R.layout.one, null));
37 views.add(inflater.inflate(R.layout.two, null));
38 views.add(inflater.inflate(R.layout.three, null));
39
40 vpAdapter = new ViewPagerAdapter(views, this);
41 vp = (ViewPager) findViewById(R.id.viewpager);
42 vp.setAdapter(vpAdapter);
43 // 下標從0開始,所以第三個頁面是get(2)。
44 start_btn = (Button) views.get(2).findViewById(R.id.start_btn);
45 start_btn.setOnClickListener(new OnClickListener() {
46 @Override
47 public void onClick(View arg0) {
48 Intent i = new Intent(Guide.this, MainActivity.class);
49 startActivity(i);
50 finish();
51 }
52 });
53 vp.setOnPageChangeListener(this);
54 }
55
56 /** 循環設置點 */
57 private void initDots() {
58 dots = new ImageView[views.size()];
59 for (int i = 0; i < views.size(); i++) {
60 dots[i] = (ImageView) findViewById(ids[i]);
61 }
62 }
63
64 @Override /** 滑動狀態改變的時候 */
65 public void onPageScrollStateChanged(int arg0) {
66 // TODO Auto-generated method stub
67 }
68
69 @Override /** 當頁面被滑動時候調用 */
70 public void onPageScrolled(int arg0, float arg1, int arg2) {
71 // TODO Auto-generated method stub
72 }
73
74 @Override /** 當前新的頁面被選中時調用 */
75 public void onPageSelected(int arg0) {
76 for (int i = 0; i < ids.length; i++) {
77 if (arg0 == i) {
78 // 亮點
79 dots[i].setImageResource(R.drawable.login_point_selected);
80 } else {
81 // 暗點
82 dots[i].setImageResource(R.drawable.login_point);
83 }
84 }
85 }
86
87 }
1 <?xml version="1.0" encoding="utf-8"?>
2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent" >
5
6 <android.support.v4.view.ViewPager
7 android:id="@+id/viewpager"
8 android:layout_width="fill_parent"
9 android:layout_height="fill_parent"
10 android:background="#00000000" >
11 </android.support.v4.view.ViewPager>
12
13 <!-- 底部三個點 -->
14 <LinearLayout
15 android:id="@+id/ll"
16 android:layout_width="fill_parent"
17 android:layout_height="wrap_content"
18 android:layout_alignParentBottom="true"
19 android:gravity="center_horizontal"
20 android:orientation="horizontal" >
21 <!-- 選中點 -->
22 <ImageView
23 android:id="@+id/iv1"
24 android:layout_width="wrap_content"
25 android:layout_height="wrap_content"
26 android:src="@drawable/login_point_selected" />
27 <!-- 未選中點 -->
28 <ImageView
29 android:id="@+id/iv2"
30 android:layout_width="wrap_content"
31 android:layout_height="wrap_content"
32 android:src="@drawable/login_point" />
33 <!-- 未選中點 -->
34 <ImageView
35 android:id="@+id/iv3"
36 android:layout_width="wrap_content"
37 android:layout_height="wrap_content"
38 android:src="@drawable/login_point" />
39 </LinearLayout>
40
41 </RelativeLayout>

㈥ Android想做一個類似新聞展示頁HTML頁面,HTML應該用什麼控制項呈現

第三方模板很多 沒必要自己弄

Html.fromHtml();中在HtmlImageGetter()中非同步載入的問題我解決了,方法是先檢查文件夾中是否存在圖片,沒有則載入默認圖片,然後一個thread去下載圖片,下載完成sendmessage,刷新TextView就可以了
Spanned sp = Html.fromHtml(html, new HtmlImageGetter(news_content,defaultDrawable),null);
news_content.setText(sp);

㈦ android開發 一開始打開的類似於歡迎頁面叫什麼

這個界面主要的作用有:

  1. 這個界面是為了讓app有更好的體驗,不會讓用戶感覺太突兀了,所以現在app市場包括ios的應用基本都是有歡迎界面的。

  2. 這個界面一般稱為啟動頁面,在android開發中,開發者可以設定在該界面的停留時間,從而可以在後台進行一些初始化的工作的。

㈧ Android Studio 怎樣實現介紹中的所見即所得的UI設計界面

在eclipse上開發android軟體,Ui設計部分主演在xml文件中實現的。開發一個android軟體,主要有三部分工作,第一個是logic,第二個resource,第三個就是ui。logic是通過在project.java文檔里的代碼實現,resourcess主要是在R.java中實現,Ui主要是在res目錄下的xml文件實現。但是模擬器缺少一個方便的所見即所得的編輯界面,我們只能通過修改xml代碼,再到模擬器中看才能達到調試的效果。而DroidDraw正好彌補了這個缺陷。先看張圖:

這張圖就是droiddraw工作的主界面,操作一目瞭然:
1.首先在screen上面編輯你想要的界面效果。widgets頁面有很多items直接拖拽到screen就可以,比如textview,button等等。
2.頁面編輯完成,點擊generate,會自動生成xml代碼,在output窗口,將代碼粘入main.xml即可,當然你還要統一res的標識符。然後運行模擬器,結果圖如下:

㈨ android studio怎麼設置引導頁

基本上現在所有的應用都會有一個歡迎界面,在歡迎界面對應用做一個整體的介紹,然後在跳入到主界面,這次要說的這個引導頁就是帶翻頁的引導頁。效果如下所示



概要實現

主要分為兩部分功能,一個是翻頁效果,一個是頁面位置指示器。為了實現翻頁效果我採用系統自帶的ViewPager對象來實現;頁面指示器則通過一個LinearLayout在其中放置相應個數的圖片,然後根據頁面的滑動動態修改各個圖片的資源。布局文件如下所示



復制代碼
1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 xmlns:tools="http://schemas.android.com/tools"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 tools:context=".MainActivity" >
6
7 <android.support.v4.view.ViewPager
8 xmlns:android="http://schemas.android.com/apk/res/android"
9 android:id="@+id/welcome_pager"
10 android:layout_width="match_parent"
11 android:layout_height="match_parent" />
12
13 <!-- 圖片位置指示器 -->
14 <LinearLayout
15 android:id="@+id/director"
16 android:layout_width="match_parent"
17 android:layout_height="wrap_content"
18 android:gravity="center_horizontal"
19 android:orientation="horizontal"
20 android:layout_marginBottom="15dip"
21 android:layout_alignParentBottom="true"
22 >
23
24 <ImageView
25 android:layout_width="wrap_content"
26 android:layout_height="wrap_content"
27 android:background="@drawable/pageindicator_on" />
28
29 <ImageView
30 android:layout_width="wrap_content"
31 android:layout_height="wrap_content"
32 android:background="@drawable/pageindicator_off" />
33
34 <ImageView
35 android:layout_width="wrap_content"
36 android:layout_height="wrap_content"
37 android:background="@drawable/pageindicator_off" />
38
39 <ImageView
40 android:layout_width="wrap_content"
41 android:layout_height="wrap_content"
42 android:background="@drawable/pageindicator_off" />
43 </LinearLayout>
44
45 </RelativeLayout>
復制代碼

ViewPager

先來看下官方解釋:Layout manager that allows the user to flip left and right through pages of data.意思是說,Viewpage是一個允許用戶在多個頁面數據之間通過左滑或者右滑的方式切換頁面數據的布局管理器。

主要功能點有兩部分,數據適配器Adapter,和事件監聽器OnPageChangeListener。數據適配器用來管理這個ViewPager對象的顯示內容,而OnPageChangeListener用來處理當頁面切換的時候的行為動作,我修改頁面指示器就是通過這個事件來完成的。

適配器



復制代碼
1 class pagerAdapter extends FragmentPagerAdapter{
2
3 public pagerAdapter(FragmentManager fm) {
4 super(fm);
5 }
6
7 @Override
8 public Fragment getItem(int arg0) {
9 //得到要顯示的對象並初始化圖片
10 WelcomeFragment fm = new WelcomeFragment();
11 fm.setImg(imgs.get(arg0));
12
13 return fm;
14 }
15
16 @Override
17 public int getCount() {
18 return imgs.size();
19 }
20
21 }
復制代碼
上面這段就是ViewPager要用的適配器了,其中imgs是一個id數組,存放了要在歡迎界面展示的圖片的id,WelcomeFragment是一個Fragment類,用來展示頁面內容,這兩個代碼會在完整代碼中體現。兩個方法需要實現,getCout,用來表示有多少個頁面;getItem,用來獲取指定位置的Pager對象。

imgs數組定義及實現:

復制代碼
1 List<Integer> imgs = null;
2 //初始化歡迎界面圖片數組
3 imgs = new ArrayList<Integer>();
4 imgs.add(R.drawable.help1);
5 imgs.add(R.drawable.help2);
6 imgs.add(R.drawable.help3);
7 imgs.add(R.drawable.help4);
復制代碼
WelcomeFragment類定義



復制代碼
1 public class WelcomeFragment extends Fragment {
2
3 View view = null;
4 int imgId ;
5 @Override
6 public View onCreateView(LayoutInflater inflater, ViewGroup container,
7 Bundle savedInstanceState) {
8 view = inflater.inflate(R.layout.welcome_fragment, null);
9
10 ImageView fragmentVw = (ImageView) view.findViewById(R.id.welcome_Img);
11 fragmentVw.setBackgroundResource(imgId);
12 return view;
13 }
14
15 /**
16 * 為該Fragment設置顯示圖片
17 * */
18 public void setImg(int imgID){
19
20 imgId = imgID;
21 }
22 }
復制代碼
WelcomeFragment布局文件

復制代碼
1 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="match_parent"
3 android:layout_height="match_parent" >
4
5 <ImageView
6 android:id="@+id/welcome_Img"
7 android:contentDescription="welcome"
8 android:layout_width="match_parent"
9 android:layout_height="match_parent" />
10
11 </FrameLayout>
復制代碼


事件監聽器OnPageChangeListener

這個監聽器用來監聽頁面切換事件,實現這個介面用來處理頁面切換時,頁面指示器跟著改變狀態。實現代碼如下

復制代碼
1 /**
2 * 頁面切換的事件監聽器
3 * */
4 class pageChangeListener implements OnPageChangeListener{
5
6 /**
7 * 當某一個頁面被選中的時候觸發
8 * */
9 @Override
10 public void onPageSelected(int arg0) {
11 int count = directorLayout.getChildCount();
12 /**
13 * 指示器自對象順序和頁面顯示順序一樣的設置為on,其餘的設置為off
14 * */
15 for(int i=0;i<count;i++){
16 ImageView iv = (ImageView) directorLayout.getChildAt(i);
17 if(i == arg0){
18 iv.setBackgroundResource(R.drawable.pageindicator_on);
19 }else{
20 iv.setBackgroundResource(R.drawable.pageindicator_off);
21 }
22 }
23 }
24
25 @Override
26 public void onPageScrolled(int arg0, float arg1, int arg2) {
27 // TODO Auto-generated method stub
28 }
29
30 @Override
31 public void onPageScrollStateChanged(int arg0) {
32 // TODO Auto-generated method stub
33 }
34 }

㈩ Android安卓歡迎頁和viewpager和Fragment的結合

<?xmlversion="1.0"encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

<RadioGroup
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<RadioButton
android:id="@+id/rb1"
android:layout_width="10dp"
android:layout_height="10dp"
android:background="@drawable/icon"
android:checked="true"
android:button="@null"/>

<RadioButton
android:id="@+id/rb2"
android:layout_width="10dp"
android:layout_height="10dp"
android:background="@drawable/icon"
android:button="@null"/>

<RadioButton
android:id="@+id/rb3"
android:layout_width="10dp"
android:layout_height="10dp"
android:background="@drawable/icon"
android:button="@null"/>
</RadioGroup>
</RelativeLayout>

********************************************************************


packagecom.example.myapplication;
importandroid.content.Intent;
importandroid.support.v4.view.ViewPager;
importandroid.support.v7.app.AppCompatActivity;
importandroid.os.Bundle;
importandroid.view.View;
importandroid.widget.RadioButton;
importandroid.widget.RadioGroup;

importjava.util.ArrayList;
importjava.util.List;

{
privateViewPagervp;
List<View>list=newArrayList<>();
RadioGrouprg;
RadioButton[]rb;
PageListenerlistener;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rg=(RadioGroup)findViewById(R.id.rg);

//實例化RadioButton的集合
rb=newRadioButton[rg.getChildCount()];
for(inti=0;i<rg.getChildCount();i++){
//從RadioGroup中循環獲取RadioButton,並放進數組
rb[i]=(RadioButton)rg.getChildAt(i);
}

vp=(ViewPager)findViewById(R.id.vp);
list.add(View.inflate(this,R.layout.view1,null));
list.add(View.inflate(this,R.layout.view2,null));
list.add(View.inflate(this,R.layout.view3,null));

MyAdapteradapter=newMyAdapter(list);
vp.setAdapter(adapter);


//單選按鈕點擊事件
rg.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){
@Override
publicvoidonCheckedChanged(RadioGroupgroup,intcheckedId){
for(inti=0;i<rg.getChildCount();i++){
//循環,如果當前RadioButton的Id和checkedId相等,就取出索引i
if(rb[i].getId()==checkedId){
//ViewPager設置當前索引項
vp.setCurrentItem(i);
break;
}
}
}
});

//vp.setOnPageChangeListener();
//添加頁面改變事件
listener=newPageListener();
vp.addOnPageChangeListener(listener);
}

publicvoidclick(Viewview){
//界面跳轉
Intentintent=newIntent(MainActivity.this,Main2Activity.class);
startActivity(intent);


}

.OnPageChangeListener{
//頁面滑動過程中執行的方法
@Override
publicvoidonPageScrolled(intposition,floatpositionOffset,intpositionOffsetPixels){

}
//頁面滑動完後執行的方法
@Override
publicvoidonPageSelected(intposition){
//頁面滑動時,把當前頁面對應的索引位置的RadioButton設置為選中狀態
rb[position].setChecked(true);
}
//滑動過程中狀態改變的方法
@Override
(intstate){

}
}

@Override
protectedvoidonDestroy(){
super.onDestroy();
//移除指定的監聽事件
vp.removeOnPageChangeListener(listener);
//清空所有的頁面改變事件
vp.clearOnPageChangeListeners();
}
}*************************************************************************


packagecom.example.myapplication;

importandroid.support.v4.view.PagerAdapter;
importandroid.view.View;
importandroid.view.ViewGroup;

importjava.util.List;


/**
*Createdby猴嫂on2017/11/18.
*/

{
List<View>list;

publicMyAdapter(List<View>list){
this.list=list;
}

@Override
publicintgetCount(){
returnlist.size();
}

@Override
publicbooleanisViewFromObject(Viewview,Objectobject){
returnview==object;
}

@Override
publicObjectinstantiateItem(ViewGroupcontainer,intposition){
container.addView(list.get(position));
returnlist.get(position);
}

@Override
publicvoiddestroyItem(ViewGroupcontainer,intposition,Objectobject){
container.removeView((View)object);
}
}

*****************************************************************

<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bb"
>

</LinearLayout>
//如上歡迎頁界面最後一個加按鈕跳轉


**********************************************************************

<?xmlversion="1.0"encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<android.support.v4.view.ViewPager
android:id="@+id/vp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<RadioGroup
android:id="@+id/rg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">

<RadioButton
android:id="@+id/rb1"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@drawable/aa"
android:button="@null"
android:gravity="center"
android:checked="true"
android:text="消息"/>
<RadioButton
android:id="@+id/rb2"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@drawable/aa"
android:button="@null"
android:gravity="center"
android:text="聯系人"/>
<RadioButton
android:id="@+id/rb3"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@drawable/aa"
android:button="@null"
android:gravity="center"
android:text="動態"/>
</RadioGroup>
</RelativeLayout>

熱點內容
qq群里上傳的文件怎麼刪除 發布:2024-04-24 22:13:21 瀏覽:357
途岳配置升級了什麼 發布:2024-04-24 21:55:55 瀏覽:886
刷機安卓10狀態欄圓角如何修復 發布:2024-04-24 21:24:00 瀏覽:135
創建sql資料庫的命令是什麼 發布:2024-04-24 21:23:58 瀏覽:43
不是安卓該如何下載畫質怪獸 發布:2024-04-24 21:18:51 瀏覽:701
php載入網頁 發布:2024-04-24 21:15:20 瀏覽:161
遠程伺服器更換ip地址 發布:2024-04-24 21:14:43 瀏覽:528
什麼時候上線華為方舟編譯器軟體 發布:2024-04-24 21:10:21 瀏覽:631
安卓布局文件指的是哪個 發布:2024-04-24 21:08:05 瀏覽:889
磁帶存儲價格 發布:2024-04-24 21:04:22 瀏覽:902