fragment的使用
新建FineTuningModeFragment

public class FineTuningModeFragment extends Fragment {         @Nullable    @Override    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {             View view = inflater.inflate(R.layout.fine_tuning_mode_layout, container, false);        return view;    }}

新建fine_tuning_mode_layout

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

使用

<fragment    android:id="@+id/fine_tuning_mode_fragment"    android:name="com.example.mydemo.hydraumaticrisetower.Fragment.RiseTowerModeFragment"    android:layout_width="wrap_content"    android:layout_height="wrap_content"/>

两个fragment切换
再新建RiseTowerModeFragment

public class RiseTowerModeFragment extends Fragment {         @Nullable    @Override    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {             View view = inflater.inflate(R.layout.rise_tower_mode_layout, container, false);        return view;    }}

新建rise_tower_mode_layout.xml

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

使用
1.

<fragment    android:id="@+id/fine_tuning_mode_fragment"    android:name="com.example.mydemo.hydraumaticrisetower.Fragment.RiseTowerModeFragment"    android:layout_width="wrap_content"    android:layout_height="wrap_content"/>改为<FrameLayout    android:id="@+id/framelayout"    android:layout_width="match_parent"    android:layout_height="wrap_content"/>

activity新增

private void replaceFragment(Fragment fragment) {         FragmentManager fragmentManager = getSupportFragmentManager();    FragmentTransaction transaction = fragmentManager.beginTransaction();    transaction.replace(R.id.framelayout, fragment);    transaction.commit();}使用replaceFragment(new RiseTowerModeFragment());replaceFragment(new FineTuningModeFragment());切换

更多相关文章

  1. Ndk配置与Demo
  2. Android:上下拖动切换界面
  3. Android(安卓)复制到剪贴板
  4. Android(安卓)图片渐变切换效果
  5. Android(安卓)官方通知工具类Notification
  6. android SQLite数据库使用实例
  7. Android(安卓)- LayoutInflater 的使用
  8. Android中TextView所带的各类属性的使用
  9. Android高级工程师每日一面试题精选!(1——15题)持续更新!

随机推荐

  1. Android(安卓)Sensor传感器系统架构初探
  2. android中AVD的使用
  3. 初识Android
  4. 【转】有关Android线程的学习
  5. 【Android】Android开发规范详解
  6. Android智能电视应用程序开发浅谈(一)
  7. Android单元测试初探——Instrumentation
  8. android:layout_gravity 和 android:grav
  9. Linux与Android的关系
  10. 【雨松MOMO】Android(安卓)软件开发与游