Java tutorial
/* * Copyright (C) 2012 Kazuya (Kaz) Yokoyama <kazuya.yokoyama@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package mobisocial.bento.todo.ui; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.ActionBar; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.view.Menu; import android.support.v4.view.MenuItem; import mobisocial.bento.todo.R; public class TodoDetailActivity extends FragmentActivity { private TodoDetailFragment mTodoDetailFragment = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_todo_detail); FragmentManager fm = getSupportFragmentManager(); mTodoDetailFragment = (TodoDetailFragment) fm.findFragmentById(R.id.fragment_todo_detail); final ActionBar actionBar = getSupportActionBar(); // set defaults for logo & home up actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_items_todo_detail, menu); super.onCreateOptionsMenu(menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; default: return mTodoDetailFragment.onOptionsItemSelected(item); } } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); } }