Created
May 28, 2013 19:39
-
-
Save YvesBill/5665491 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package com.YvesB.Nexus; | |
//Importare | |
import android.app.ActionBar; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.view.MenuItem; | |
//Definire il Layout che verrà utilizzato | |
public class About extends Activity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
//Settare la presenza della Action Bar | |
ActionBar ab = getActionBar(); | |
ab.setHomeButtonEnabled(true); | |
ab.setDisplayHomeAsUpEnabled(true); | |
} | |
//Definire l'intento al click dell'icona | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
//switch consente di creare dei casi per determinare gli intenti oggetto per oggetto | |
switch (item.getItemId()) { | |
case android.R.id.home: | |
Intent intent = new Intent(this, MainActivity.class); | |
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |
startActivity(intent); | |
return true; | |
//FLAG_ACTIVITY_CLEAR_TOP è l'intento di ritornare alla Activity precedente | |
default: | |
return super.onOptionsItemSelected(item); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment