リストビューアイテムに次のレイアウトを使用しています。
<?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>
これは私のアクティビティの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);
}
android.R.layout.simple_list_item_1 を使用すると、すべてが正常に機能するため、それは私の simple_list_item_1 に関連するものだと思います