安卓開發學習筆記—————《Anroid編程權威指南》使用RecyclerView顯示列表
阿新 • • 發佈:2018-10-11
開發 eat view pan add cti sta activit super
使用抽象activity托管fragment
抽象activity類
public abstract class SingleFragmentActivity extends AppCompatActivity { protected abstract Fragment createFragment(); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fragment);FragmentManager fm=getSupportFragmentManager(); Fragment fragment=fm.findFragmentById(R.id.fragment_container); if(fragment==null) { fragment=createFragment(); fm.beginTransaction().add(R.id.fragment_container,fragment).commit(); } } }
安卓開發學習筆記—————《Anroid編程權威指南》使用RecyclerView顯示列表