Reputation: 539
I'm trying to edit an item in my RecyclerView but I don't know how to pass the information (e.g. position in the list, values it holds) to the EditItem activity. Here is how I'm detecting the tap:
rvBucketItem = (RecyclerView) findViewById(R.id.rvBucketItemList);
ItemList = BucketItem.initializeTaskList(1);
BucketItemAdapter adapterBucket = new BucketItemAdapter(this, ItemList);
rvBucketItem.setAdapter(adapterBucket);
rvBucketItem.setLayoutManager(new LinearLayoutManager(this));
rvBucketItem.setOnClickListener(new RecyclerView.OnClickListener()
{
@Override
public void onClick(View view)
{
Intent intent = new Intent(MainBucketActivity.this, EditItem.class);
startActivity(intent);
}
});
I know that you can store items into the list using the putExtra()
method but I don't know how I'd get the items themselves.
Upvotes: 0
Views: 252
Reputation: 34250
please refer below code
rvBucketItem.addOnItemTouchListener(
new RecyclerItemClickListener(context, new RecyclerItemClickListener.OnItemClickListener() {
@Override public void onItemClick(View view, int position) {
// TODO Handle item click with view and given position
}
})
);
Upvotes: 1
Reputation: 779
I think you are looking for a Bundle, this way you can transmit Data to the new activity.
Bundles are generally used for passing data between various Android activities. It depends on you what type of values you want to pass, but bundles can hold all types of values and pass them to the new activity.
Here is the link -> What is a "bundle" in an Android application
Upvotes: 0