底部按钮

fragment布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.handmark.pulltorefresh.library.PullToRefreshScrollView
        android:id="@+id/hoem_news_ptsv"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                android:layout_gravity="center"
                app:cardCornerRadius="4dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:orientation="horizontal">

                    <ImageView
                        android:id="@+id/home_news_img"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="3" />

                    <TextView
                        android:id="@+id/home_news_text"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:layout_gravity="center"
                        android:layout_weight="2" />
                </LinearLayout>
            </android.support.v7.widget.CardView>


            <application.com.ayy.lenovo.zy0502.ui.MyList
                android:id="@+id/hoem_news_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></application.com.ayy.lenovo.zy0502.ui.MyList>
        </LinearLayout>
    </com.handmark.pulltorefresh.library.PullToRefreshScrollView>
</LinearLayout>

news_activity

public class NewsActivity extends BaseActivity {
    private DrawerLayout news_drawer;
    private RadioGroup news_radio;
    private NavigationView news_nav;

    @Override
    public void initView() {
        news_radio = findViewById(R.id.news_radio);
        news_nav = findViewById(R.id.news_nav);
        news_drawer = findViewById(R.id.news_drawer);
    }

    @Override
    public void setView() {
        setFragment(new Fragment_Home());
    }

    @Override
    public int getLayout() {
        return R.layout.activity_news;
    }

    @Override
    public void setLinstener() {
        news_radio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.radio1:
                        setFragment(new Fragment_Home());
                        break;
                    case R.id.radio2:
                        setFragment(new Fragment_Find());
                        break;
                    case R.id.radio3:
                        setFragment(new Fragment_Self());
                        break;
                }
            }
        });
        news_nav.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.nav_item1:
                        Toast.makeText(NewsActivity.this, "nav_item1", Toast.LENGTH_SHORT).show();
                        news_drawer.closeDrawers();
                        break;
                    case R.id.nav_item2:
                        Toast.makeText(NewsActivity.this, "nav_item2", Toast.LENGTH_SHORT).show();
                        news_drawer.closeDrawers();
                        break;
                    case R.id.nav_item3:
                        Toast.makeText(NewsActivity.this, "nav_item3", Toast.LENGTH_SHORT).show();
                        news_drawer.closeDrawers();
                        break;
                    case R.id.nav_item4:
                        Toast.makeText(NewsActivity.this, "nav_item4", Toast.LENGTH_SHORT).show();
                        news_drawer.closeDrawers();
                        break;
                    case R.id.nav_item5:
                        Toast.makeText(NewsActivity.this, "nav_item5", Toast.LENGTH_SHORT).show();
                        news_drawer.closeDrawers();
                        break;
                }
                return false;
            }
        });
    }

    private void setFragment(Fragment fragment) {
        getSupportFragmentManager().beginTransaction().replace(R.id.news_frame, fragment).commit();
    }
}

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值