我的Android應用程序讓我從logcat的這個錯誤:了java.lang.RuntimeException:RuntimeException的機器人
致您的內容必須有一個 的ListView其id屬性爲 'android.R.id.list'
這是我的代碼:
package com.WNF;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.app.ListActivity;
import android.content.Intent;
public class Actiemenu extends ListActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView (R.layout.actiemenu);
final String[] array = new String[] {
"Ding", "AnderDing", "Nogeending", "laatseding"
};
setListAdapter(new ArrayAdapter<String> (this, R.layout.actiemenu, array));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
if (position == 0) {
Intent een = new Intent(v.getContext(), Acties.class);
startActivity(een);
}
else if (position == 1) {
Intent twee = new Intent(v.getContext(), Acties2.class);
startActivity(twee);
}
}
});
getIntent();
}
}
任何想法可能是問題?
刪除'的setContentView()' – xandy
顯示你的XML佈局。 –
@xandy你確定嗎?但爲什麼 ? –