欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

RadioButton+ViewPager+FragmentPagerAdapter快

系統 1737 0
一切為了快速開發

開發類似界面
RadioButton+ViewPager+FragmentPagerAdapter快速搭建頁面結構

    
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.RadioButton;

import com.yirui.youbao.App;
import com.yirui.youbao.fragment.ParkingPayedListFragment;
import com.yirui.youbao.fragment.ParkingUnpayListFragment;

/**
 * 
 * @author pythoner
 *
 */
public class ParkingPayActivity extends BaseActivity implements View.OnClickListener{

	private final int count = 2;//頁數
	private int curPosition=0;//當前頁
	private RadioButton[] rbs;
	private ViewPager viewPager;
	private FragmentPagerAdapter pagerAdapter;
	private Fragment[] fragments;
    
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_parking_pay);
		initActionBar("App付費");
		initViews();
	}
	
	private void initViews() {
		initIndicator();
		initViewPager();
	}

	private void initIndicator(){
		rbs = new RadioButton[count];
		rbs[0] = (RadioButton) findViewById(R.id.rb_0);
		rbs[1] = (RadioButton) findViewById(R.id.rb_1);

		for (int i = 0; i < rbs.length; i++) {
			rbs[i].setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					String tag = (String) v.getTag();
					curPosition=Integer.parseInt(tag);
					viewPager.setCurrentItem(curPosition);
				}
			});
		}
		
		rbs[curPosition].setChecked(true);
	}
	
	private void initViewPager(){
		fragments = new Fragment[count];
		fragments[0] = ParkingUnpayListFragment.newInstance();
		fragments[1] = ParkingPayedListFragment.newInstance();

		pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
			@Override
			public int getCount() {
				return fragments.length;
			}

			@Override
			public Fragment getItem(int position) {
				return fragments[position];
			}

		};

		viewPager = (ViewPager) findViewById(R.id.viewPager);
		viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

			@Override
			public void onPageSelected(int position) {
				// TODO Auto-generated method stub
				rbs[position].setChecked(true);
				curPosition=position;
			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
			}

			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub

			}
		});

		viewPager.setAdapter(pagerAdapter);
		viewPager.setCurrentItem(curPosition);
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
	}
	
}

  


    
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg_gray"
    android:orientation="vertical" >

    <include layout="@layout/actionbar_comm" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:padding="8dp" >

        <RadioGroup
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:orientation="horizontal" >

            <RadioButton
                android:id="@+id/rb_0"
                android:tag="0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_blue_trans_with_frame"
                android:button="@null"
                android:paddingBottom="4dp"
                android:paddingLeft="8dp"
                android:paddingRight="8dp"
                android:paddingTop="4dp"
                android:text="未付費"
                android:textColor="@color/textcolor_blue_white_radio" />

            <RadioButton
                android:id="@+id/rb_1"
                android:tag="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_blue_trans_with_frame"
                android:button="@null"
                android:paddingBottom="4dp"
                android:paddingLeft="8dp"
                android:paddingRight="8dp"
                android:paddingTop="4dp"
                android:text="已付費"
                android:textColor="@color/textcolor_blue_white_radio" />
        </RadioGroup>
    </FrameLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:flipInterval="30"
        android:background="@android:color/white"
        android:layout_marginTop="16dp"
        android:persistentDrawingCache="animation" />

</LinearLayout>

  


背景:
    
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_checked="true">
        <shape>
            <solid android:color="@color/primary" />
            <stroke android:width="1dp" android:color="@color/primary" />
            <corners android:topLeftRadius="dp" android:topRightRadius="0dp" android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp"/>
        </shape>
   	</item>
    <item>
        <shape>
            <solid android:color="@android:color/transparent" />
            <stroke android:width="1dp" android:color="@color/primary" />
            <corners android:topLeftRadius="dp" android:topRightRadius="0dp" android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp"/>
        </shape>
    </item>

</selector>

  


文字顏色:
    
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:color="@android:color/white" />
    <item android:color="@color/primary" />
</selector>

  

RadioButton+ViewPager+FragmentPagerAdapter快速搭建頁面結構


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日本成人在线网站 | 日韩城人网站 | 国产在线精品一区 | 亚洲精品欧美一区二区三区 | jizz国产精品免费麻豆 | 国内精品久久久久久中文字幕 | 午夜在线 | 久久99深爱久久99精品 | 久草天堂 | 国产精品不卡一区 | 人人干操 | 最新日本中文字幕在线观看 | 五月天色丁香 | 一级片免费 | 国产深夜福利在线观看网站 | 欧洲一区二区 | 可以看的毛片 | 狠狠色丁香婷婷综合久久片 | 国产黑丝在线播放 | 欧美日韩一区二区中文字幕视频 | 日本特黄的免费大片视频 | 人人香蕉 | 操操影视 | 一道本视频在线观看 | 波多野结衣精品一区二区三区 | 婷婷亚洲五月琪琪综合 | 国产精品福利视频手机免费观看 | 亚洲精品久久久久久久久久久久久 | 韩日在线视频 | 亚洲第一中文字幕 | 九九有点热 | 一区二区视频在线观看 | 碰碰碰人人澡人人爱摸 | 免费无码毛片一区二区A片 成人18网站 | 国产精品久久久久亚洲 | 免费国产免费福利视频 | 日韩欧美视频免费观看 | 久久久久久国产精品久久 | 二区三区偷拍浴室洗澡视频 | 99je全部都是精品视频在线 | 国产麻豆精品 |