How to pass value from 1st activity to 3rd activity

前端 未结 7 1984
暖寄归人
暖寄归人 2020-12-12 07:25

I wish to pass the value from 1st activity to 3rd activity.

My 1st activity: CustomizedListview

2nd activity is: SingleMenuItemActivity

3rd activity

7条回答
  •  天涯浪人
    2020-12-12 08:13

    You can pass the value in 2 ways:

    1. Either you make a global Class and set the value in that class and access that class in your 3rd activity
    2. You can use Intent to send your values from 1st activity to 2nd activity

    Intent intent = new Intent (this, 2ndActivity.class); 
        intent.putExtra ("Value",Value);
        startActivity(intent);
    

    And the same you can do for 2nd activity to 3rd activity

    Bundle extras = getIntent().getExtras();
        if(extras!=null){
        Values=extras.getString("value");
        }
    

提交回复
热议问题