Avinash Jaiswal Avinash Jaiswal - 1 year ago 53
Android Question

How to use clickable edittexts which intents to some other layout but on return not lose any data from previous intent?

I am trying to create a layout such that there are two clickable edittexts and onClick of those Edittexts, layout is redirected to some other layout where the user has to choose something. But my question is how to achieve this as I am losing past intent data. When I am clicking on first and then clicking on second then the data returned by the first intent disappears. How do I get a solution for this issue?

Answer Source

Ok I give you simple startActivityForResult example, can you try this :

In your first Activity :

//declaring this globally would be good
private final int REQUEST_CODE_OTHER_ACTIVITY=0x1;
Intent i=new Intent(this,SecondActivity.class);

then add this method to catch returning Intents :

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode != RESULT_OK) {

    switch (requestCode) {

            Bundle extras=data.getExtras();
    super.onActivityResult(requestCode, resultCode, data);

So in your second Activity use like that to return data :

Intent returnIntent = new Intent();
String salute="Hello | привет | Hallo | Merhaba | Bonjour" ;
Bundle extras = new Bundle();

Please refer this link : Using Intents to Create Flows

Also this too : Result

There is another way is using Fragments for dynamic layouts. Please try something make some effort, edit your question than I can help you easily.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download