How to pass value using Intent between Activity in Android?

前端 未结 7 1497
面向向阳花
面向向阳花 2020-12-01 16:48

I want to pass the value of the position in one activity class to another...

My code is as follows:

protected void onListItemClick(ListView listView,         


        
7条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 17:20

    You can use :

    In first activity ( MainActivity page )

    Intent i = new Intent(MainActivity.this,SecondActivity.class); 
    i.putExtra("YourValueKey", yourData.getText().toString());
    

    then you can get it from your second activity by :
    In second activity ( SecondActivity page )

    Intent intent = getIntent();
    String YourtransferredData = intent.getExtras().getString("YourValueKey");
    

提交回复
热议问题