Post editText-content with TextView in more than one activity

时间:2018-02-03 10:02:40

标签: android android-intent

I know how to get the input from EditText and send it to the next activity using:

btn_blob.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent intent = new Intent(getApplicationContext(), NextActivity.class);
        intent.putExtra((EXTRA_PRIZE), prize_detail);
        startActivity(intent);
    }
});

But, I only get the EditText input in this NextActivity.java. How can I get and display the EditText input with a textView in more than one activity? Also, in the header of the DrawerLayout, there should be a TextView with this content.

1 个答案:

答案 0 :(得分:0)

So, you want to share text written in edittext of your activity across multiple activity.

now, main things to know is how to pass data (text written in your edittext of your activity) across multiple activity.

there can be many ways to do it. Use based on your project structure and requirement.

  1. Pass your data through bungle to each and every activity.
  2. Store your data in SharedPreference and read from it whenever you need to display.
  3. Make one singleton object and store your data in that. Whenever you need it, you can read from same singleton object.
  4. You can store in database and read from same.