投掷时ListView滚动速度很慢

时间:2014-09-11 19:33:46

标签: android android-layout android-activity android-listview image-loading

使用listview显示图片和名称。我遇到的问题是当我浏览listview时它有一个非常不连贯的卷轴。我使用Android查询库来加载图像。我在logcat中释放了很多GC_FOR ALLOC。不确定是什么导致它。有什么帮助吗?

    listview xml :

         <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="70dp" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:orientation="horizontal" >

        <RelativeLayout 
           android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            >

              <ImageView

                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_centerInParent="true"
                android:src="@drawable/grey2" />

            <ImageView

                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_centerInParent="true"
                android:src="@drawable/grey2" />
        </RelativeLayout>
      <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:layout_width="wrap_content"

                android:layout_height="wrap_content" />

            <TextView
                android:layout_width="wrap_content"

                android:layout_height="wrap_content" />
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

getview方法:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
         final  ViewHolder holder;
            // convertView = null;
            if (convertView == null) {
                convertView = LayoutInflater.from(context).inflate(
                        R.layout.layout, parent, false);

                holder = new ViewHolder();


                holder.pic=(ImageView)convertView.findViewById(R.id.pic);
            holder.fname=(TextView)convertView.findViewById(R.id.fname);
                holder.name=(TextView)convertView.findViewById(R.id.name);

                convertView.setTag(holder);


            } else {
                holder = (ViewHolder) convertView.getTag();


            }

          aq2= aq.recycle(convertView);
        holder.name.setText(first_name + " " + last_name );
            holder.username.setText(username);


        q2.id(holder.pic).image(urrl);



        return convertView;
    }



static  public class ViewHolder {

        TextView fname;
        TextView name;
        ImageView pic;


    }

0 个答案:

没有答案