androidclassvariablesandroid-recyclerviewonitemclick

How to send value from onItemClick RecycleView to other java class


 @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    String clicktemplate = modelClassesListt.get(i).getTitle();
    Toast.makeText(Template.this ,modelClassesListt.get(i).getTitle() , Toast.LENGTH_SHORT).show();
}

I want to send this clicktemplate string value to other class


Solution

  • You have to put value in Intent or Bundle and send it to the next screen.

    Here is an example for pass data in Activity.

    Intent intent = new Intent(this, YourNextActivity.class);
                    intent.putExtra("key_clicktemplate", clicktemplate);
                    startActivity(intent);
    

    To get value in next screen like below

    String value = getIntent().getExtras().getString("key_clicktemplate");