私には私の活動があります。Android 4.2では完全に動作しますが、2.3(エミュレーターと実際のデバイスの両方)で実行すると、白い画面が表示され(下部にのみ「次の」アイテムのいくつかのピクセルが表示されます)、すべてが表示されますスクロールを開始します。
リスト:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/category_browser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:dividerHeight="1dp"
tools:listitem="@layout/category_browser_list_item" >
</ListView>
アイテム:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/category_browser_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:background="#ffffff"
android:clickable="true"
android:gravity="fill"
android:orientation="horizontal" >
<ImageView
android:id="@+id/category_browser_list_icon"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="fill"
android:layout_weight="0"
android:background="#ffffff"
android:contentDescription="@+id/category_browser_list_item_description"
android:src="@drawable/icon" />
<TextView
android:id="@+id/category_browser_list_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/category_browser_title"
android:textColor="#000000"
android:textSize="24sp" />
<CheckBox
android:id="@+id/category_browser_list_checkbox"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:clickable="false" />
</LinearLayout>
コード:
protected LinearLayout getListElementView() {
View listItem = inflator.inflate(R.layout.category_browser_list_item, null);
LinearLayout listElement = (LinearLayout)listItem.findViewById(R.id.category_browser_list_item);
return listElement;
}
public class CategoryListAdapter extends BaseAdapter {
@Override
public int getCount() {
int count = null != categories && null != categories.categories ? categories.categories.size() : 0;
Log.d(TAG, "getCount:" + count);
return count;
}
@Override
public Category getItem(int position) {
return null != categories && null != categories.categories ? categories.categories.get(position) : null;
}
@Override
public long getItemId(int position) {
return position;
}
// create a new ImageView for each item referenced by the Adapter
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout listView = null;
if (convertView != null) { // if it's not recycled, initialize some attributes
listView = (LinearLayout)convertView;
}
if (listView == null) { // if it's not recycled, initialize some attributes
listView = getListElementView();
}
final Category category = getItem(position);
category.setListView(listView);
File cacheIconFile = category.getCacheIconFile();
ImageView imageView = (ImageView)listView.findViewById(R.id.category_browser_list_icon);
if (cacheIconFile.exists()) {
imageView.setImageURI(Uri.fromFile(cacheIconFile));
} else {
Drawable noIcon = getResources().getDrawable(R.drawable.icon);
imageView.setImageDrawable(noIcon);
}
// Log.i(TAG, category.name + ": " + category.iconUrl + ": " + category.downloadBaseUrl);
if (null != category.name) {
TextView textView = (TextView)listView.findViewById(R.id.category_browser_list_title);
textView.setText(category.name);
}
listView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//start downloading category with downloadmanager
//(category);
Intent intent = category.getIntent();
if (null != intent)
startActivity(intent);
else {
category.setStatus(Category.CategoryDownloadStatus.DOWNLOADING);
downloadLocalePackage(category);
}
}
});
return listView;
}
}