抽屉加点击按钮

main_layout

<android.support.v4.widget.DrawerLayout
    android:id="@+id/dl_root"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <FrameLayout
            android:layout_height="0dp"
            android:layout_width="match_parent"
            android:id="@+id/fram_layout"
            android:layout_weight="9"/>

        <RadioGroup
            android:layout_height="0dp"
            android:layout_width="match_parent"
            android:id="@+id/radio_group"
            android:orientation="horizontal"
            android:layout_weight="1">

            <RadioButton
                android:layout_height="match_parent"
                android:layout_width="0dp"
                android:id="@+id/rb_first"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="首页"/>

            <RadioButton
                android:layout_height="match_parent"
                android:layout_width="0dp"
                android:id="@+id/rb_xigua"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="西瓜视频"/>

        </RadioGroup>

    </LinearLayout>

    <LinearLayout

        android:layout_height="match_parent"

        android:layout_width="240dp"

        android:orientation="vertical"

        android:layout_gravity="start"

        android:background="#595353">

        <ImageView

            android:layout_height="wrap_content"

            android:layout_width="wrap_content"

            android:layout_gravity="center_horizontal"

            android:src="@mipmap/ic_launcher_round"/>

        <TextView

            android:layout_height="wrap_content"

            android:layout_width="match_parent"

            android:gravity="center_horizontal"

            android:text="网易小王子"/>

        <ListView

            android:layout_height="wrap_content"

            android:layout_width="match_parent"

            android:id="@+id/list_drawer"/>

    </LinearLayout>

</android.support.v4.widget.DrawerLayout>

-------MainActivity

//初始化控件
dl_root = findViewById(R.id.dl_root);
list_drawer = findViewById(R.id.list_drawer);
fram_layout = findViewById(R.id.fram_layout);
radio_group = findViewById(R.id.radio_group);


list = new ArrayList<>();
list.add("我的音乐");
list.add("我的会员");
list.add("我的网盘");
list.add("我的关注");

list_drawer.setAdapter(new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,list));

dl_root.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);

//intiActionBar();

 

private void intiActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    mToggle = new ActionBarDrawerToggle(this, dl_root, R.string.open, R.string.close);
    mToggle.syncState();
    dl_root.addDrawerListener(mToggle);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if(mToggle.onOptionsItemSelected(item)){
        return true;
    }
    return super.onOptionsItemSelected(item);
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值