私はAndroid開発のコツをつかもうとしていますが、問題が発生しました。ListViewがあり、ランダムなアイテムを入力したくありません。しかし、リストビューのアダプタを設定しようとすると、アプリケーションフォースが閉じます。
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/accountList"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
MainActivity.java:
package com.testapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends Activity {
static final String[] TEXTS = new String[] {"test1","test2"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView lv = (ListView) this.findViewById(R.id.accountList);
lv.setAdapter(new ArrayAdapter<String>(this, R.id.accountList, TEXTS));
}
}
私は何が間違っているのですか?
logcat:
05-20 13:44:28.154: E/AndroidRuntime(585): FATAL EXCEPTION: main
05-20 13:44:28.154: E/AndroidRuntime(585): android.content.res.Resources$NotFoundException: Resource ID #0x7f060000 type #0x12 is not valid
05-20 13:44:28.154: E/AndroidRuntime(585): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2110)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.content.res.Resources.getLayout(Resources.java:857)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.AbsListView.obtainView(AbsListView.java:2033)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.ListView.measureHeightOfChildren(ListView.java:1244)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.ListView.onMeasure(ListView.java:1155)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.View.measure(View.java:12723)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.View.measure(View.java:12723)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.View.measure(View.java:12723)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.View.measure(View.java:12723)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
05-20 13:44:28.154: E/AndroidRuntime(585): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2092)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.View.measure(View.java:12723)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.os.Looper.loop(Looper.java:137)
05-20 13:44:28.154: E/AndroidRuntime(585): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-20 13:44:28.154: E/AndroidRuntime(585): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 13:44:28.154: E/AndroidRuntime(585): at java.lang.reflect.Method.invoke(Method.java:511)
05-20 13:44:28.154: E/AndroidRuntime(585): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-20 13:44:28.154: E/AndroidRuntime(585): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-20 13:44:28.154: E/AndroidRuntime(585): at dalvik.system.NativeStart.main(Native Method)