简体   繁体   中英

switch activity and send string as an extra to another activity

I have a TabLayoutObjectActivity that shows 2 tabs with a different activity( TabActivity1 & TabActivity2 ).

I have another activity called ObjectActivity . It contains an array and if it is clicked I want the app to change to the TabLayoutObjectActivity (which shows TabActivity1 first) and sends a string from an array that clicked to TabActivity1 .

I have tried some code but the app always wants to force close after I click one of the array list.

        Intent i = null;
        i = new Intent(this, TabLayoutObjekActivity.class);

        Intent ii = null;
        ii = new Intent(this, TabActivity1.class);
        ii.putExtra("name", String.valueOf(menuArray[position].toString()));

        startActivity(i);
        startActivity(ii);

Please give me your opinion how to do this. Thanks :)

Refer to this . It explains how to solve your problem in detail. onclick even you can handle the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM