侧滑菜单xml和代码
来源:互联网 发布:淘宝怎样绑定手机号 编辑:程序博客网 时间:2024/06/18 19:58
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer">
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/lin_content">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/lin_content">
</LinearLayout>
<LinearLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="start"
android:id="@+id/menu"
android:background="#f0f">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lv"></ListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
//代码部分
ListView listView= (ListView) findViewById(R.id.lv);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
linearLayout = (LinearLayout) findViewById(R.id.menu);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
linearLayout = (LinearLayout) findViewById(R.id.menu);
lists.add(new TabBean("新闻","1"));
lists.add(new TabBean("关注","2"));
lists.add(new TabBean("动态","3"));
lists.add(new TabBean("设置","4"));
listView.setAdapter(new MyAdapter(this,lists));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//关闭侧滑菜单
drawerLayout.closeDrawer(linearLayout);
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//关闭侧滑菜单
drawerLayout.closeDrawer(linearLayout);
//只将 菜单 对应的类型 传过去
Bundle bundle=new Bundle();
bundle.putString("key",lists.get(position).getType());
ContentFragment cf=new ContentFragment();
cf.setArguments(bundle);
Bundle bundle=new Bundle();
bundle.putString("key",lists.get(position).getType());
ContentFragment cf=new ContentFragment();
cf.setArguments(bundle);
//动态添加一个fragment
getSupportFragmentManager().beginTransaction().replace(R.id.lin_content,cf).commit();
getSupportFragmentManager().beginTransaction().replace(R.id.lin_content,cf).commit();
}
});
});
阅读全文
0 0
- 侧滑菜单xml和代码
- AttachXMLForSelect:XML自动关联多级SELECT菜单代码和例子
- AttachXMLForSelect:XML自动关联多级SELECT菜单代码和
- AttachXMLForSelect:XML自动关联多级SELECT菜单代码和
- 横滑菜单和侧拉菜单
- Flash+XML生成动态导航菜单代码
- android侧滑菜单功能代码
- xml布局侧拉菜单
- Android底部菜单和侧滑菜单的综合应用
- 创建程序菜单和快捷方式的代码
- 创建程序菜单和快捷方式的代码
- 11 PopupMenu菜单和代码例子
- xml和代码实现Animation
- 使用少量代码实现自己的RecyclerView侧滑菜单
- DrawerLayout侧滑菜单的布局,注意事项及代码
- 侧滑菜单和viewpager冲突
- ListView和RecyclerView侧滑菜单
- DrawerLayout和Navigation实现侧滑菜单
- MVP和sqlite数据库,XRecyclerView上啦加载下拉刷新的第三方注册登录,列表
- 6.16
- 【java】求1-10的和。
- 【Angular2】AnswerSheet组件设计
- 14 个你可能不知道的 JavaScript 调试技巧
- 侧滑菜单xml和代码
- ROI Pooling层详解
- HDU
- 链表相关练习题
- 简单实现断点续传+MVP+Retrofit+RxJava
- 简单的断点传送,不需理解,粘贴运行
- 通国轮廓进行抠图 掩膜
- F1
- ECS访问RDS超时504的解决方法