I am new to Android programming and was working on a card layout. I was wondering, how do I make it clickable?
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
I have that on my card widget and then I wanted to know where to put an on clickable action? I want to be able to click the card, it gets the id of the card, and then displays a new intent activity
This is my code for the activity to load the adapter
setContentView(R.layout.activity_my);
RecyclerView recList = (RecyclerView) findViewById(R.id.cardList);
recList.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(this);
llm.setOrientation(LinearLayoutManager.VERTICAL);
recList.setLayoutManager(llm);
ContactAdapter ca = new ContactAdapter(createList(30));
recList.setAdapter(ca);
If you used the implementation correctly, your code should go like this:
In your implementation of the onClickListener, you should have this:
that is pretty much all you need to start a new activity from the card