Last active
August 29, 2015 14:13
-
-
Save realdm/b5499a6e66b956ae863b to your computer and use it in GitHub Desktop.
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
package com.app.mungoi.minhaprimeiraapp; | |
import android.content.Intent; | |
import android.support.v7.app.ActionBarActivity; | |
import android.os.Bundle; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import android.widget.TextView; | |
public class SegundaActivity extends ActionBarActivity { | |
private TextView mLabelNome; | |
private static final String CHAVE_NOME="nome"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_segunda); | |
mLabelNome = (TextView)findViewById(R.id.mLabelNome); | |
//Pega o intent que foi passado ao inciar a activity | |
Intent intent = getIntent(); | |
//Pega o valor do extra com a chave passada como parametro | |
String nome = intent.getExtras().getString(CHAVE_NOME); | |
//mostra o nome no TextView | |
mLabelNome.setText("Ola o seu nome e: "+nome); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
getMenuInflater().inflate(R.menu.menu_segunda, menu); | |
return true; | |
} | |
@Override | |
public boolean onOptionsItemSelected(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(); | |
//noinspection SimplifiableIfStatement | |
if (id == R.id.action_settings) { | |
return true; | |
} | |
return super.onOptionsItemSelected(item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment