How to pass values from RecycleAdapter to MainActivity or Other Activities

前端 未结 6 1163
小蘑菇
小蘑菇 2020-12-12 16:04

I am working on a shopping cart app,Items are displayed as below.There is a plus, minus (+/-) buttons to choose the number of quantity.

If product quantity is chang

6条回答
  •  醉梦人生
    2020-12-12 16:13

    //Simply it works for me
    //In onBindViewHolder of RecyclerAdapter write the following code on clickEvent of any view;
    
    
    Intent intent = new Intent(tContext, TargetActivity.class);
    intent.putExtra("key", "value");
    tContext.startActivity(intent);
    
    
    //TargetActivity.java
    
      String str = getIntent().getStringExtra("key");
    //You got the value as String :)
    

提交回复
热议问题