ListView在4.4 KitKat上有错误吗?

时间:2015-05-27 23:09:59

标签: android android-layout listview android-listview

我正在使用Lucas的TwoWayView library来创建水平ListView。 一切正常GS3Galaxy Note 2 Android 4.1.2& Android 4.3

但是,我在我的同事Motorola G Android 4.44上安装了我的应用,ListView没有显示任何图像。我可以点击它们,但我看不到任何图像。它只显示红色或透明的颜色。

ListView Adpater:

public class ListViewAdapter extends BaseAdapter {
    private List<ListViewObject> ObjectList;
    private Context mContext;

    public ListViewAdapter(Context context, List<ListViewObject> newList){
    this.mContext = context;
    this.ObjectList = newList;
}

@Override
public int getCount() {
    return ObjectList.size();
}

@Override
public ListViewObject getItem(int position) {
    return ObjectList.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {       
  ViewHolder viewHolder = new ViewHolder();

  LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  if (convertView == null) {
      convertView = inflater.inflate(R.layout.listview_layout, parent, false);
      viewHolder.imageView = (ImageView)convertView.findViewById(R.id.ListViewImage); 
      viewHolder.layout = (RelativeLayout)convertView.findViewById(R.id.ListViewLayout);
      convertView.setTag(viewHolder);            
  } 
 else 
  {
     viewHolder = (ViewHolder)convertView.getTag();
  }

  Picasso.with(mContext)
  .load(getItem(position).getImageUrl())
  .resize(100, 100)  
  .centerCrop()
  .into(viewHolder.imageView);   

  return convertView;
}

class ViewHolder {
    RelativeLayout layout;
    ImageView imageView;
   }
 }

ListView布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ListViewLayout"    
android:layout_width="52dp"
android:layout_height="43dp" >

<ImageView
    android:id="@+id/ListViewImage"
    android:layout_width="50dp"
    android:layout_height="40dp"
    android:scaleType="fitXY"
    android:layout_marginLeft="2px"
    android:layout_marginTop="2px" />

主要布局:

<org.lucasr.twowayview.TwoWayView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/TwoWayView"
    style="@style/TwoWayView"
    android:layout_width="match_parent"
    android:layout_height="43dp"
    android:layout_marginTop="595dp"
    android:background="@color/transparent"
    android:drawSelectorOnTop="true" />

MainActivity:

 public void ListView_Load() {
        for (File file : listFile){
            mListViewObject = new ListViewObject();
            mListViewObject.setImageUrl("file:///" + file.getAbsolutePath());
            ListViewObject_List.add(mListViewObject); 
        }        
        listViewAdapter = new ListViewAdapter(this, ListViewObject_List);
        TwoWayListView.setAdapter(listViewAdapter);
} 

有人可以请指导我吗?

非常感谢你的帮助。

0 个答案:

没有答案