Java tutorial
/* * ThingDetailActivity.java: Activity to display details of a Thing. ** * 2012 Steven Casagrande (scasagrande@galvant.ca) and * Christopher E. Granade (cgranade@cgranade.com). * This file is a part of the ThingPool Server project. * Licensed under the AGPL version 3. ** * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ca.galvant.thingpool.client; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.NavUtils; import android.view.MenuItem; public class ThingDetailActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_thing_detail); getActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { Bundle arguments = new Bundle(); arguments.putString(ThingDetailFragment.ARG_ITEM_ID, getIntent().getStringExtra(ThingDetailFragment.ARG_ITEM_ID)); ThingDetailFragment fragment = new ThingDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction().add(R.id.thing_detail_container, fragment).commit(); } } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { NavUtils.navigateUpTo(this, new Intent(this, ThingListActivity.class)); return true; } return super.onOptionsItemSelected(item); } }