因此,我的onListItemClick
由於某種原因不起作用。我在另一個活動中使用相同的代碼結構,並且一個工作正常。當我嘗試在這裏實現相同的方法時,它根本不起作用。 Toast
不起作用。而注意力的意圖也不起作用。我確定我的命名和標籤是好的。列表項目甚至不覺得它們是可點擊的。有人可以幫我在這裏嗎?onListItemClick不起作用
public class MainActivity extends ListActivity {
String objectId;
protected List<ParseObject> mInfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_info);
//**** There is a bunch of code here that takes import the list view from an adapter. I believe they are working fine. ***//
}
//**** this part below is not working. This is the section where if you click on the list item, it brings you to the detailactivity.
@Override
protected void onListItemClick(ListView l,View v, int position, long id){
super.onListItemClick(l, v, position, id);
ParseObject infoObject = mInfo.get(position);
String objectId = infoObject.getObjectId();
Toast.makeText(getApplicationContext(),objectId, Toast.LENGTH_SHORT).show();
Intent Details = new Intent(MainActivity.this, DetailsActivity.class);
Details.putExtra("objectId", objectId);
startActivity(Details);
}
你是否將偵聽器設置爲listView?像'listview.setOnItemClickListener'? –
嗨,好心地顯示logcat警告和錯誤 – Sheychan
號。我該怎麼做?以及如何做到這一點?爲什麼我需要這個?我在沒有setOnItemClickListener的另一個活動中使用此代碼,並且它工作正常。 –