zoukankan      html  css  js  c++  java
  • Fragment

    // 创建一个Fragment->   PlaceholderFragment

    public class PlaceholderFragment extends Fragment { // android.support.v4.app.Fragment;
    
        public PlaceholderFragment() {}
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragement_main, container, false);
    
            rootView.findViewById(R.id.btnShowAnotherFrament).setOnClickListener(new View.OnClickListener(){
                public void onClick(View v) {
             // 启动另外一个 Fragment getFragmentManager().beginTransaction() .addToBackStack(
    null) // 添加后退栈 不然的后退的话没有效果 .replace(R.id.container, new AnotherFragment()) // 在这个容器里面替换 新的Fragment .commit(); } }); rootView.findViewById(R.id.btnStartSliderActivity).setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { getFragmentManager().popBackStack(); } }); return rootView; } }

    PlaceholderFragment对应的视图

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity$PlaceholderFragment">
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="呈现另一个Fragement"
            android:id="@+id/btnShowAnotherFrament" />
    </LinearLayout>

    // 2. 从主 MainActivity中加载PlaceholderFragment

     protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment())
                        .commit();
            }
            System.out.println("onCreate");
        }
  • 相关阅读:
    storm源码分析之topology提交过程
    storm启动supervisor源码分析-supervisor.clj
    storm启动nimbus源码分析-nimbus.clj
    storm shell命令源码分析-shell_submission.clj
    storm定时器timer源码分析-timer.clj
    Storm在zookeeper上的目录结构
    storm操作zookeeper源码分析-cluster.clj
    Four subspaces
    拉格朗日量(函数)、达朗贝尔原理、哈密顿量
    离散正弦信号的周期
  • 原文地址:https://www.cnblogs.com/shaoshao/p/5866928.html
Copyright © 2011-2022 走看看