Issue
Hi guys ive been wanting to open to another activity when any of the item within the recycler view has been clicked or pressed. And when i declaring the intent like this it gave me this error
Cannot resolve constructor 'Intent(com.example.fyptest1.RoomAdapter, java.lang.Class<com.example.fyptest1.staffSpecificRoomActivity>)'
This here is the code
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View viewer) {
Intent intent = new Intent(RoomAdapter.this,staffSpecificRoomActivity.class);
}
});
And when i change to "this" it gave me error as well, my program is not using fragment so getApplication context is not usable right?
Cannot resolve constructor 'Intent(anonymous android.view.View.OnClickListener, java.lang.Class<com.example.fyptest1.staffSpecificRoomActivity>)'
Intent intent = new Intent(this,staffSpecificRoomActivity.class);
Solution
Just add this "viewer" to the line of code and ure good to go
Intent intent = new Intent(viewer.getContext(),staffSpecificRoomActivity.class);
Answered By - Joshua Tabi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.