zoukankan      html  css  js  c++  java
  • FragmentManager V4包下 应该用FragmentActivity

    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    
    public class MainActivity extends FragmentActivity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.news_articles);
    
            // Check that the activity is using the layout version with
            // the fragment_container FrameLayout
            if (findViewById(R.id.fragment_container) != null) {
    
                // However, if we're being restored from a previous state,
                // then we don't need to do anything and should return or else
                // we could end up with overlapping fragments.
                if (savedInstanceState != null) {
                    return;
                }
    
                // Create an instance of ExampleFragment
                HeadlinesFragment firstFragment = new HeadlinesFragment();
                
                // In case this activity was started with special instructions from an Intent,
                // pass the Intent's extras to the fragment as arguments
                firstFragment.setArguments(getIntent().getExtras());
                
                // Add the fragment to the 'fragment_container' FrameLayout
                getSupportFragmentManager().beginTransaction()
                        .add(R.id.fragment_container, firstFragment).commit();
            }
        }
    }
  • 相关阅读:
    vuex 命名空间
    vue-touchjs
    Jackson最简单用法
    Bootstrap登录样式
    Left/Right/Inner Join用法和区别
    VS2015安装提示出现“安装包丢失或损坏”解决方法
    HTML之禁止输入文本
    jQuery之call()方法的使用
    jQuery操作cookie
    jQuery常用的查找Dom元素方法
  • 原文地址:https://www.cnblogs.com/bimingcong/p/4952812.html
Copyright © 2011-2022 走看看