原因を探ろうとしているのですが、よくわかりません。私は見て、見て、私が想定していたすべてを入力したことを確信しています。以下に私のコードを掲載します。
アダプタ クラス:
public class MyAgendaAdapter extends BaseAdapter {
ArrayList<Agenda> agendas = new ArrayList<Agenda>();
public MyAgendaAdapter() {
agendas.add(new Agenda());
}
@Override
public int getCount() {
return agendas.size();
}
@Override
public Object getItem(int position) {
return agendas.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
convertView = inflater.inflate(R.layout.agenda, parent, false);
}
Agenda agenda = agendas.get(position); //get the agenda from the ArrayList
TextView nameTextView = (TextView) convertView.findViewById(R.id.agenda_name);
nameTextView.setText(agenda.getEvent());
TextView timeTextView = (TextView) convertView.findViewById(R.id.agenda_time);
timeTextView.setText(agenda.getTime());
TextView locationTextView = (TextView) convertView.findViewById(R.id.agenda_location);
locationTextView.setText(agenda.getLocation());
return convertView;
}
}
主な活動クラス:
public class MainDisplayActivity extends Activity {
MyAgendaAdapter agendaAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView list = (ListView) findViewById(R.id.agenda_list);
agendaAdapter = new MyAgendaAdapter();
list.setAdapter(agendaAdapter);
}
}
インポートを省略しました。私のレイアウトとIDが正しいと仮定すると、誰が問題を知っていますか?
編集(logcatの正確なエラー):
05-27 17:29:54.839: W/dalvikvm(1065): threadid=1: thread exiting with uncaught exception(group=0x409c01f8)
05-27 17:29:54.860: E/AndroidRuntime(1065): FATAL EXCEPTION: main
05-27 17:29:54.860: E/AndroidRuntime(1065): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zeroe/com.zeroe.MainDisplayActivity}: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.os.Handler.dispatchMessage(Handler.java:99)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.os.Looper.loop(Looper.java:137)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-27 17:29:54.860: E/AndroidRuntime(1065): at java.lang.reflect.Method.invokeNative(Native Method)
05-27 17:29:54.860: E/AndroidRuntime(1065): at java.lang.reflect.Method.invoke(Method.java:511)
05-27 17:29:54.860: E/AndroidRuntime(1065): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-27 17:29:54.860: E/AndroidRuntime(1065): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-27 17:29:54.860: E/AndroidRuntime(1065): at dalvik.system.NativeStart.main(Native Method)
05-27 17:29:54.860: E/AndroidRuntime(1065): Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.widget.AdapterView.addView(AdapterView.java:471)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.view.LayoutInflater.rInflate(LayoutInflater.java:743)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-27 17:29:54.860: E/AndroidRuntime(1065): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.Activity.setContentView(Activity.java:1835)
05-27 17:29:54.860: E/AndroidRuntime(1065): at com.zeroe.MainDisplayActivity.onCreate(MainDisplayActivity.java:21)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.Activity.performCreate(Activity.java:4465)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-27 17:29:54.860: E/AndroidRuntime(1065): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-27 17:29:54.860: E/AndroidRuntime(1065): ... 11 more