Created
May 15, 2014 23:48
-
-
Save booknara/1e0357dba3dac608c2f4 to your computer and use it in GitHub Desktop.
Android Activity BoilerPlate Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Android Activity BoilerPlate Code | |
* | |
* @author Daehee Han (bookdori81@gmail.com) | |
* @since 05/15/2014 | |
* @version 1.0.0 | |
* | |
*/ | |
import android.app.ActionBar; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
public class BaseActivity extends Activity { | |
private static final String CNAME = BaseActivity.class.getSimpleName(); | |
private ActionBar actionBar; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_base_activity); | |
configureActionBar(); | |
} | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
} | |
@Override | |
protected void onStop() { | |
super.onStop(); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
getMenuInflater().inflate(R.menu.base_activity, menu); | |
return true; | |
} | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
switch (item.getItemId()) { | |
case android.R.id.home: | |
onBackPressed(); | |
return true; | |
} | |
return super.onOptionsItemSelected(item); | |
} | |
private void configureActionBar() { | |
actionBar = getActionBar(); | |
actionBar.setDisplayShowHomeEnabled(true); | |
actionBar.setDisplayShowTitleEnabled(true); | |
} | |
public Context getContext() { | |
return this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment