私はリストビューアイテムに次のレイアウトを使用しています。ListViewのアイテムレイアウトエラー
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://scheme.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dip"
android:textSize="18sp"
android:minHeight="40sp"
/>
しかし、logcat java.lang.RuntimeExceptionでエラーが発生しました。あなたはlayout_width引数を指定する必要があります。
私のmain.xmlは
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget28"
android:background="#ff000033"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="70px"
android:layout_height="30px"
android:paddingLeft="2px"
android:paddingTop="2px"
android:background="@drawable/ic_launcher"
></ImageView>
<ListView
android:id="@+id/myListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
であり、これは、私はそれが私がandroid.R.layoutを使用している場合ので、私のsimple_list_item_1に関連する何かがあると思う私の活動ののonCreateコード
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
context=this.getApplicationContext();
this.setTitle("NP Headline News");
myListView=(ListView)findViewById(R.id.myListView);
myListView.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View v, int index,long id) {
// TODO Auto-generated method stub
String urlAddress=urlAddresses[index];
String urlCaption = urlsCaptions[index];
}
});
int layoutId=R.layout.simple_list_item_1;
// int layoutId=android.R.layout.simple_list_item_1;
aa = new ArrayAdapter<String>(this,layoutId,this.urlsCaptions);
myListView.setAdapter(aa);
}
です。 simple_list_item_1その後すべて正常に動作します
あなたは完全なエラーテキストを投稿できます –
RuntimeExceptionがこのレイアウトを参照していますか?それは正しいようです... listviewレイアウトも貼り付けてください。 –