我,說:「OnItemClickListener不能被解析爲一個類型」當我輸入驗證碼錯誤:OnItemClickListener
package com.funkystudios.android.facts;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class activity2 extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] Facts = getResources().getStringArray(R.array.Facts_Array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list, Facts));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
Toast.LENGTH_SHORT).show();
}
});
}
}
它發生就在「lv.setOnItemClickListener(新OnItemClickListener(){」。我不知道我在做什麼錯。
您還沒有進口OnItemClickListener錯誤 – kiki 2010-10-14 04:34:41