Advertisement
khamim

Untitled

Jul 19th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.12 KB | None | 0 0
  1.  
  2. import android.content.Intent;
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.EditText;
  7. import android.widget.TextView;
  8. public class SecondActivity extends AppCompatActivity {
  9.     public static final String EXTRA_REPLY =
  10.             "com.example.khamim.twoactivities.extra.REPLY";
  11.  
  12.     private EditText mReply;
  13.  
  14.     @Override
  15.     protected void onCreate(Bundle savedInstanceState) {
  16.         super.onCreate(savedInstanceState);
  17.         setContentView(R.layout.activity_second);
  18.         mReply = (EditText) findViewById(R.id.editText_second);
  19.  
  20.         Intent intent = getIntent();
  21.         String message =
  22.                 intent.getStringExtra(MainActivity.EXTRA_MESSEGE);
  23.  
  24.         TextView textView = (TextView) findViewById(R.id.text_message);
  25.         textView.setText(message);
  26.     }
  27.     public void returnReply(View view) {
  28.         String reply = mReply.getText().toString();
  29.         Intent replyIntent = new Intent();
  30.         replyIntent.putExtra(EXTRA_REPLY, reply);
  31.         setResult(RESULT_OK, replyIntent);
  32.         finish();
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement