嗨,伙計們,當單擊或按下回收站視圖中的任何專案時,我一直想打開另一個活動。當我像這樣宣告意圖時,它給了我這個錯誤
無法決議建構式'Intent(com.example.fyptest1.RoomAdapter, java.lang.Class<com.example.fyptest1.staffSpecificRoomActivity>)'
這是代碼
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View viewer) {
Intent intent = new Intent(RoomAdapter.this,staffSpecificRoomActivity.class);
}
});
當我更改為“this”時,它也給了我錯誤,我的程式沒有使用片段,所以 getApplication 背景關系不可用對嗎?
無法決議建構式'Intent(anonymous android.view.View.OnClickListener, java.lang.Class<com.example.fyptest1.staffSpecificRoomActivity>)'
Intent intent = new Intent(this,staffSpecificRoomActivity.class);
uj5u.com熱心網友回復:
只需將此“查看器”添加到代碼行中就可以了
Intent intent = new Intent(viewer.getContext(),staffSpecificRoomActivity.class);
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/420630.html
標籤:
