第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

RadioButton 切換按鈕 做類似QQ 消息與電話

標(biāo)簽:
Android

直接上图

5bba1b39000132a604500860.jpg

类似QQ 中 消息与电话按钮切换:

记得使用RadioButton 做切换按钮的时候一定要 嵌套在RadioGroup 里面,布局文件如下

[代码]xml代码:

?

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

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

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#DCDCDC"

    android:orientation="vertical">

 

    <RelativeLayout

        android:id="@+id/rl"

        android:layout_width="match_parent"

        android:layout_height="45dp"

        android:layout_marginBottom="10dp"

        android:layout_marginTop="10dp">

 

        <RadioGroup

            android:id="@+id/select"

            android:layout_width="200dp"

            android:layout_height="match_parent"

            android:layout_centerInParent="true"

            android:orientation="horizontal">

 

            <RadioButton

                android:id="@+id/dialUp"

                android:layout_width="match_parent"

                android:layout_height="match_parent"

                android:layout_gravity="center_vertical"

                android:layout_weight="1"

                android:background="@drawable/radiobutton_left_bg"

                android:button="@null"

                android:checked="true"

                android:gravity="center"

                android:text="拨号"

                android:textColor="@drawable/text_select" />

 

            <RadioButton

                android:id="@+id/contacts"

                android:layout_width="match_parent"

                android:layout_height="match_parent"

                android:layout_gravity="center_vertical"

                android:layout_weight="1"

                android:background="@drawable/radiobutton_right_bg"

                android:button="@null"

                android:gravity="center"

                android:text="联系人"

                android:textColor="@drawable/text_select" />

        </RadioGroup>

    </RelativeLayout>

 

    <View

        android:id="@+id/view"

        android:layout_width="match_parent"

        android:layout_height="2px"

        android:layout_below="@+id/rl"

        android:background="#D3D3D3" />

 

    <FrameLayout

        android:id="@+id/franme_meun"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:layout_below="@+id/view"

        android:background="#FFFFFF" />

</RelativeLayout>

 

代码如下:

[代码]java代码:

?

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

public class HomeActivity   extends AppCompatActivity   {

    private RadioGroup mSelect;

    //拨号

    private RadioButton mDialUp;

    //联系人

    private RadioButton mContacts;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_home);

 

        findView();

    }

 

    private void findView() {

 

        mDialUp   = (RadioButton) findViewById(R.id.dialUp);

        mContacts   = (RadioButton) findViewById(R.id.contacts);

        mSelect   = (RadioGroup) findViewById(R.id.select);

        mSelect.setOnCheckedChangeListener(listener);

 

        //   设置默认显示页面

        Fragment   dialUp = new DialUpFragment();

        FragmentManager   fmangerhp = getFragmentManager();

        FragmentTransaction   ftranhp = fmangerhp.beginTransaction();

        ftranhp.replace(R.id.franme_meun,   dialUp);

        ftranhp.commit();

 

    }

 

    private RadioGroup.OnCheckedChangeListener   listener = new RadioGroup.OnCheckedChangeListener()   {

 

        @Override

        public void onCheckedChanged(RadioGroup group, int checkedId) {

            //   TODO Auto-generated method stub

            switch (checkedId) {

                case R.id.dialUp:

                    //   这里是你想要跳转的界面

                    Fragment   dialUp = new DialUpFragment();

                    FragmentManager   fmangerhp = getFragmentManager();

                    FragmentTransaction   ftranhp = fmangerhp.beginTransaction();

                    ftranhp.replace(R.id.franme_meun,   dialUp);

                    ftranhp.commit();

                    mDialUp.setChecked(true);

                    break;

 

                case R.id.contacts:

                    //   这里是你想要跳转的界面

                    Fragment   contacts = new ContactsFragment();

                    FragmentManager   sanManager = getFragmentManager();

                    FragmentTransaction   sanfTransaction = sanManager.beginTransaction();

                    sanfTransaction.replace(R.id.franme_meun,   contacts);

                    sanfTransaction.commit();

 

                    break;

 

                default:

                    break;

            }

        }

 

    };

}

原文链接:http://www.apkbus.com/blog-455907-61209.html

點擊查看更多內(nèi)容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學(xué)

大額優(yōu)惠券免費領(lǐng)

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消