-4

I am trying to do something like, when I click on "Button_Set" Button on Activity 1, it should set the Edit Box of Activity 2. I know the below code gives the Null pointer exception and is expected to not work.

Any Idea how do I do this?

order.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(Activity1.this,Activity2.class));
                setorder.setText("Welcome User");

           }
  });
Yash Pawse
  • 41
  • 10
  • @pappbence96 i don't think this is duplicate question. He just want to transfer user to new activity and set text to edittext or textview. Welcome String. – Ashish Aug 17 '19 at 10:00
  • 1
    If he wants to pass the welcoming string from the first activity, then it's a duplicate. If he doesn't, it's a little convoluted attempt to a simple problem (baking the text into the XML) – pappbence96 Aug 17 '19 at 10:16
  • @pappbence96, No. Thank you, that solved my query. Possibly I couldn't get the exact keywords for searching the above answer.. – Yash Pawse Aug 17 '19 at 10:21
  • 1
    If the linked duplicate solved your issue, please select the "That solved my problem!" option, so this question will be marked as such. – Mike M. Aug 17 '19 at 10:33

1 Answers1

0
button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(FirstActivity.this,SecondActivity.class));
           }
      });
bishal
  • 13
  • 5