Android笔记一(Fragment和ActionBar的使用)
?
? ?其实说白了,就是Activity的一个子集。Fragment也有自己的生命周期,比Activity多出好几个。Fragment也可以使用layout.xml的文件来创建一个界面,但是不同于Activity,Fragment是通过在onCreateView中加载布局文件。
?
//ActionBar点击触发事件public boolean onOptionsItemSelected(MenuItem item) {switch(item.getItemId()) {case android.R.id.home: //当点击的是返回导航键时 Intent intent = new Intent(this, Main.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);startActivity(intent);this.finish();return true;default:return super.onOptionsItemSelected(item);}}}?
?