Created
December 12, 2017 05:13
-
-
Save Crowbrammer/a71137dbc1df2ec8ed29fd1c2dafb378 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 tech.understated.myfirstapp; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.widget.TextView; | |
public class DisplayMessageActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_display_message); | |
// Get the Intent that started this activity and extract the string | |
Intent intent = getIntent(); | |
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); | |
// Capture the layout's TextView and set the string as its text | |
TextView textView = findViewById(R.id.textView); | |
textView.setText(message); | |
} | |
} |
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 tech.understated.myfirstapp; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.EditText; | |
import static android.provider.AlarmClock.EXTRA_MESSAGE; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
/** Called when the user taps the Send button */ | |
public void sendMessage(View view) { | |
// Do something in response to button | |
Intent intent = new Intent(this, DisplayMessageActivity.class); | |
EditText editText = (EditText) findViewById(R.id.editText); | |
String message = editText.getText().toString(); | |
intent.putExtra(EXTRA_MESSAGE, message); | |
startActivity(intent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment