解决方案 »
- android 通过LayoutInflater获得View,但是如何获得View里的控件
- Android3.2平台Map应用FC异常日志分析
- 一个布局问题
- JAVA层进程AIDL 如何使用binder 和c++层的进程通信。C++ 层没有AIDL啊
- 关于一个android自定义控件属性的问题?
- Android 2.3写文件问题(4.0可行,快崩溃了,求大神!)
- 看看这句话是啥意思
- Android Socket 创建失败 加上权限就秒退 是什么情况?
- Android开发中判断网络链接的问题
- 关于安卓应用的服务器端开发
- viewpager多页隐藏的问题
- 运行时控制台总是出现emulator-5554 disconnected
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/bg_slidingmenu_left"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="40dp"
android:paddingLeft="60dp"
android:paddingTop="20dp" > <!-- 11111111 --> <RelativeLayout
android:id="@+id/rlivtv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView1"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_home" /> <TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView1"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView1"
android:text="首 页"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout> <!-- 222222 --> <RelativeLayout
android:id="@+id/rlivtv2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView2"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_news" /> <TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView2"
android:gravity="center"
android:text="新 闻"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout>
<!-- 3333333 --> <RelativeLayout
android:id="@+id/rlivtv3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView3"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_affairs" /> <TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView3"
android:gravity="center"
android:text="政 务"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout>
<!-- 4444444 --> <RelativeLayout
android:id="@+id/rlivtv4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView4"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_live" /> <TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView4"
android:gravity="center"
android:text="直 播"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout>
<!-- 55555555 --> <RelativeLayout
android:id="@+id/rlivtv5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView5"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_demand" /> <TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView5"
android:gravity="center"
android:text="点 播"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout>
<!-- 66666666 --> <RelativeLayout
android:id="@+id/rlivtv6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView6"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_project" /> <TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView6"
android:gravity="center"
android:text="专 题"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout>
<!-- 777777777 --> <RelativeLayout
android:id="@+id/rlivtv7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView7"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_image" /> <TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView7"
android:gravity="center"
android:text="图 片"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout>
<!-- 88888888 --> <RelativeLayout
android:id="@+id/rlivtv8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView8"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_radio" /> <TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView8"
android:gravity="center"
android:text="广 播"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout>
<!-- 99999999 --> <RelativeLayout
android:id="@+id/rlivtv9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingTop="20dp" > <ImageView
android:id="@+id/imageView9"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/biz_navigation_tan_subscribe" /> <TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/imageView9"
android:gravity="center"
android:text="订 阅"
android:textColor="#99ffffff"
android:textSize="18dp" />
</RelativeLayout></LinearLayout>
首先,思想是点击导航,把导航需要显示的布局fragmen替换到主布局文件中布局,用replace方法替换。你先搜一下fragmen怎么用,再搜下这个方法replace(),应该就差不多了。
public void menuItemClicked(int position) {
menu.showContent();// 点击关闭
switch (position) {
case 0:
Toast.makeText(getApplicationContext(), "遥信检测", 0).show();
fragmentManager.beginTransaction()
.replace(R.id.homefragment, new HomeFragment()).commit();
break;
case 1:
Toast.makeText(getApplicationContext(), "遥控监测", 0).show();
fragmentManager.beginTransaction()
.replace(R.id.homefragment, new YaokongFragment()).commit();
break;
case 2:
Toast.makeText(getApplicationContext(), "载波通信", 0).show();
fragmentManager.beginTransaction()
.replace(R.id.homefragment, new ZaibotongxinFragment())
.commit();
break;
case 3:
Toast.makeText(getApplicationContext(), "信号强度", 0).show();
fragmentManager.beginTransaction()
.replace(R.id.homefragment, new XinhaoqiangduFragment())
.commit();
break;
case 4:
Toast.makeText(getApplicationContext(), "电表抄读", 0).show();
fragmentManager.beginTransaction()
.replace(R.id.homefragment, new DianbiaochaoduFragment())
.commit();
break;
case 5:
Toast.makeText(getApplicationContext(), "脉冲检测", 0).show();
fragmentManager.beginTransaction()
.replace(R.id.homefragment, new MaichongjianceFragment())
.commit();
break;
default:
break;
}