<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    L遷客

    技術博客
    隨筆 - 1, 文章 - 12, 評論 - 1, 引用 - 0
    數據加載中……

    Android 高仿QQ 界面滑動效果

    Android 高仿QQ 界面滑動效果

    點擊或者滑動切換畫面,用ViewPager實現,

     

     

    首先是布局文件:

    <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:orientation="vertical" >

        <LinearLayout

            android:layout_width="match_parent"

            android:layout_height="62dip"

            android:orientation="vertical"  

            android:background="@drawable/top_theme_blue">

            <LinearLayout

                android:layout_width="match_parent"

                android:layout_height="36dip"

                android:orientation="horizontal"  

                android:gravity="center_vertical">

                <ImageView

                    android:id="@+id/main_avatar"

                    android:layout_width="32dip"

                    android:layout_height="32dip"

                    android:src="@drawable/avatar" />

                <TextView  

                    android:id="@+id/main_nick"

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:textColor="#FFFFFF"

                    android:text="Vestigge"/>

                <ImageView  

                    android:layout_width="14dip"

                    android:layout_height="14dip"

                    android:src="@drawable/status_online"/>

            </LinearLayout>

            <LinearLayout

                android:layout_width="match_parent"

                android:layout_height="26dip"

                android:orientation="horizontal"  

                android:gravity="bottom">

                <RadioGroup    

                    android:id="@+id/main_radiogroup"

                    android:orientation="horizontal"

                    android:paddingTop="1dp"  

                    android:layout_width="fill_parent"    

                    android:layout_height="wrap_content">  

                    <RadioButton    

                        android:id="@+id/main_radio_recent"    

                        android:checked="true"    

                        android:text="動態"  

                        android:textColor="@color/tab_text"

                        android:drawableBottom="@drawable/top_tab_selector"

                        style="@style/radio_style"/>      

                    <RadioButton    

                        android:id="@+id/main_radio_buddy"  

                        android:text="群組"

                        android:textColor="@color/tab_text"  

                        android:drawableBottom="@drawable/top_tab_selector"

                        style="@style/radio_style"/>  

                    <RadioButton    

                        android:id="@+id/main_radio_group"    

                        android:text="好友"  

                        android:textColor="@color/tab_text"

                        android:drawableBottom="@drawable/top_tab_selector"

                        style="@style/radio_style"

                        android:checked="true"/>

                    <RadioButton    

                        android:id="@+id/main_radio_trends"    

                        android:text="會話"  

                        android:textColor="@color/tab_text"

                        android:drawableBottom="@drawable/top_tab_selector"

                        style="@style/radio_style"/>

                </RadioGroup>    

            </LinearLayout>

        </LinearLayout>

        <android.support.v4.view.ViewPager

            android:id="@+id/main_viewpager"

            android:layout_width="match_parent"

            android:layout_height="match_parent" >

        </android.support.v4.view.ViewPager>    

    </LinearLayout>

    代碼:

     

    public class MainActivity extends ActivityGroup {

        private static final String TRENDS="動態";

        private static final String GROUP="群組";

        private static final String BUDDY="好友";

        private static final String RECENT="會話";

        private ArrayList<View> pageViews;

        private RadioGroup radioGroup;

        private ViewPager viewPager;

     

        public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            requestWindowFeature(Window.FEATURE_NO_TITLE);

            setContentView(R.layout.activity_main);

            

            initView();

            viewPager=(ViewPager) findViewById(R.id.main_viewpager);

            viewPager.setAdapter(new PagerAdapter(){

                public int getCount() {

                    return pageViews.size();

                }

                public boolean isViewFromObject(View view, Object objcet) {

                    return view==objcet;

                }

                //這里會對需要進行水平切換的頁面進行了加載和初始化 android:tileMode="repeat" 

                public Object instantiateItem(View view, int id) {

                    ((ViewPager)view).addView(pageViews.get(id));

                    return pageViews.get(id);

                }

                public void destroyItem(View view, int id, Object arg2) {  

                    ((ViewPager) view).removeView(pageViews.get(id));  

                }

            });

            viewPager.setCurrentItem(2);//默認顯示的是好友頁面 

            radioGroup = (RadioGroup) findViewById(R.id.main_radiogroup);

            radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                public void onCheckedChanged(RadioGroup group, int checkedId) {

                    setClick(checkedId);

                }

            });

        }

        

        void initView() {

            pageViews=new ArrayList<View>();

            View view1 = getLocalActivityManager().startActivity(TRENDS,

                    new Intent(this, TrendsActivity.class)).getDecorView();

            View view2 = getLocalActivityManager().startActivity(GROUP,

                    new Intent(this, GroupActivity.class)).getDecorView();

            View view3 = getLocalActivityManager().startActivity(BUDDY,

                    new Intent(this, BuddyActivity.class)).getDecorView();

            View view4 = getLocalActivityManager().startActivity(RECENT,

                    new Intent(this, RecentActivity.class)).getDecorView();

            pageViews.add(0,view1);

            pageViews.add(1,view2);

            pageViews.add(2,view3);

            pageViews.add(3,view4);

        }

     

        public void setClick(int id) {

            switch(id){

            case R.id.main_radio_trends:

                viewPager.setCurrentItem(0);

                break;

            case R.id.main_radio_group:

                viewPager.setCurrentItem(1);

                break;

            case R.id.main_radio_buddy:

                viewPager.setCurrentItem(2);

                break;

            case R.id.main_radio_recent:

                viewPager.setCurrentItem(3);

                break;

            }

        }

        @Override

        public boolean onCreateOptionsMenu(Menu menu) {

            getMenuInflater().inflate(R.menu.activity_main, menu);

            return true;

        }

    }

    posted on 2013-02-24 16:46 L遷客 閱讀(214) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 99久久99这里只有免费费精品| 国产男女猛烈无遮挡免费视频网站 | 亚洲成a人片在线网站| 中文字幕影片免费在线观看| jizzjizz亚洲日本少妇| 亚洲成AV人片在线观看WWW| 无码免费午夜福利片在线 | 亚洲综合综合在线| 国产伦一区二区三区免费| 中文字幕免费不卡二区| 亚洲熟妇AV一区二区三区浪潮| jlzzjlzz亚洲乱熟在线播放| 精品无码免费专区毛片| 无码精品人妻一区二区三区免费| 久久久久亚洲av无码专区导航| 日本一道本高清免费| 亚洲视频在线免费观看| 国产尤物在线视精品在亚洲| 亚洲AV综合色区无码二区爱AV| 免费国产成人午夜私人影视| 无码日韩精品一区二区三区免费| 怡红院亚洲红怡院在线观看| 亚洲精品高清国产一久久| 免费乱码中文字幕网站| 免费看污成人午夜网站| a级毛片免费高清毛片视频| 亚洲精品乱码久久久久久V | 中国在线观看免费的www| 亚洲AV综合永久无码精品天堂| 午夜亚洲国产理论秋霞| 亚洲精品成人网久久久久久 | 亚洲国产另类久久久精品小说 | 久久久久亚洲Av无码专| 亚洲综合AV在线在线播放| 国产在线播放免费| 日韩精品成人无码专区免费| 69精品免费视频| 中文字幕无码一区二区免费| 一区二区三区免费看| 美女被免费网站在线视频免费| 亚洲精品午夜国产va久久|