packagecom.example.textviewedittext;importandroid.support.v7.app.ActionBarActivity;importandroid.support.v7.app.ActionBar;importandroid.support.v4.app.Fragment;importandroid.os.Bundle;importandroid.view.LayoutInflater;importandroid.view.Menu;importandroid.view.MenuItem;importandroid.view.View;importandroid.view.ViewGroup;importandroid.os.Build;public class MainActivity extendsActionBarActivity {
@Overrideprotected voidonCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container,newPlaceholderFragment())
.commit();
}
}
@Overridepublic booleanonCreateOptionsMenu(Menu menu) {//Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);return true;
}
@Overridepublic booleanonOptionsItemSelected(MenuItem item) {//Handle action bar item clicks here. The action bar will//automatically handle clicks on the Home/Up button, so long//as you specify a parent activity in AndroidManifest.xml.
int id =item.getItemId();if (id ==R.id.action_settings) {return true;
}return super.onOptionsItemSelected(item);
}/*** A placeholder fragment containing a simple view.*/
public static class PlaceholderFragment extendsFragment {publicPlaceholderFragment() {
}
@OverridepublicView onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView= inflater.inflate(R.layout.fragment_main, container, false);returnrootView;
}
}
}