滚动时Listview卡住了吗?

时间:2014-07-03 09:41:48

标签: android listview

我正在使用listview来显示图像,但是在滚动时它就会发现我知道为什么我也使用了Lazyloading,我也只显示没有图像的文本然后它也会被打击请告诉我这是什么问题?

这是我的xml布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@drawable/wallshadow"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:id="@+id/layout_ImageSlider"
        android:layout_width="fill_parent"
          android:background="#ffffff"
        android:layout_height="wrap_content" >


        <RelativeLayout 
            android:id="@+id/movingheader"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"

            >

            <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:padding="5dp"
            android:text="Question is loading...."
            android:textColor="#2b2b2b"
            android:textSize="@dimen/questiontextsize"
            android:textStyle="bold" />

              <RelativeLayout
                  android:layout_below="@+id/textView1"
                android:layout_width="fill_parent"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:layout_height="4dp"
                android:background="#D4AF37" > 
            </RelativeLayout>


        </RelativeLayout>





        <RelativeLayout
            android:layout_below="@+id/movingheader"
            android:id="@+id/layoutImageContainer"
            android:layout_width="match_parent"
            android:layout_height="@dimen/wallViewPagerParent"
              >

          <android.support.v4.view.ViewPager
              android:id="@+id/pager"
              android:layout_width="match_parent"
               android:layout_height="@dimen/wallSliderParent"
              android:layout_marginBottom="0dp"
              android:layout_marginLeft="0dp"
              android:background="@drawable/full_img"
              android:layout_marginRight="0dp" />

            <ImageView
                android:id="@+id/imageview_userImage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/pager"
                android:layout_alignParentBottom="true"
                android:layout_marginLeft="4dp"
                android:src="@drawable/profile_pic_frame" />


            <RelativeLayout 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/pager"

                android:layout_marginLeft="-3dp"
                android:layout_marginTop="8dp"
                android:layout_toRightOf="@+id/imageview_userImage"
                >
            <TextView
                android:id="@+id/textVew_WallUserName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"


                android:text="TextView"
                android:textColor="#2b2b2b"
                android:textSize="@dimen/nametextsize"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textView_PostDate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textVew_WallUserName"

                android:layout_marginTop="3dp"

                android:text="TextView"
                android:textColor="#D6D6D6"
                android:textSize="@dimen/datetextsize"
                android:textStyle="bold" />

            </RelativeLayout>
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/layoutImageContainer"
            android:layout_marginTop="5dp"
            android:background="@drawable/commentsandokayborder"
            android:paddingBottom="7dp"
            android:paddingTop="10dp" >

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/textVew_WallTotalokayTEXT"
                android:layout_toRightOf="@+id/imageView1"
                android:text=""
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="20dp"
                android:layout_centerVertical="true"
                android:src="@drawable/ok_icon" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:layout_marginTop="2dp"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/textVew_WallTotalComments"
                android:src="@drawable/comments_iocn" />

            <TextView
                android:id="@+id/textVew_WallTotalComments"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="4dp"
                android:layout_marginRight="20dp"
                android:text="0"
                android:textColor="#D4AF37"
                android:textSize="@dimen/commenttextGoldensize"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textVew_WallTotalokay"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="3dp"
                android:layout_toRightOf="@+id/imageView1"
                android:text="0"
                android:textColor="#D4AF37"
                android:textSize="@dimen/okaytextGoldensize"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textVew_WallTotalokayTEXT"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/imageView1"
                android:layout_margin="2dp"
                android:layout_toRightOf="@+id/textVew_WallTotalokay"
                android:text=" "
                android:textColor="#2b2b2b"
                android:textSize="@dimen/okaytextsize" />

        </RelativeLayout>

    </RelativeLayout>


    <!-- textVew_WallTotalokay -->
</RelativeLayout>





public class WallLatestAdapter extends BaseAdapter {

    //Variables

    Activity activity;
    private List<okayWallProps> data;
    LayoutInflater mInflater;
    protected boolean isScrolling=false;
    mageLoaderWallUserImage imageLoader;
    private static int[] pagePositon;
    public WallLatestAdapter(Activity act, List<okayWallProps> wallData, ListView lst){


        pagePositon = new int[10000];

        activity=act;
        data=wallData;
        mInflater=  (LayoutInflater) activity
                .getApplicationContext().getSystemService(
                        Context.LAYOUT_INFLATER_SERVICE);

                /*LayoutInflater.from(act);*/
        imageLoader=new mageLoaderWallUserImage(act);

    }


    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        viewHolder holder;
        if(convertView==null)
        {
            convertView=mInflater.inflate(R.layout.adapter_walllayout, parent,false);
            holder=new viewHolder();

            holder.questionName = (TextView) convertView.findViewById(R.id.textView1);
            holder.questionName.setTypeface(fontsFamily.getFont(activity, true));

            holder.commentDount = (TextView) convertView.findViewById(R.id.textVew_WallTotalComments);

            holder.okayCount = (TextView) convertView.findViewById(R.id.textVew_WallTotalokay);

            holder.userImage = (ImageView) convertView.findViewById(R.id.imageview_userImage);

            holder.date = (TextView) convertView.findViewById(R.id.textView_PostDate);
            holder.date.setTypeface(fontsFamily.getNameFont(activity));

            holder.userName = (TextView) convertView.findViewById(R.id.textVew_WallUserName);
            holder.userName.setTypeface(fontsFamily.getNameFont(activity));

            holder.ViewPager_Images = (ViewPager) convertView.findViewById(R.id.pager);











            convertView.setTag(holder);
        }
        else
        {
            holder = (viewHolder) convertView.getTag();
        }






        holder.questionName.setText(data.get(position).wallPost_Name);

        holder.commentDount.setText(spanString.changeStringSpanWall(data.get(position).wallPost_Images_Data
                .get(0).qst_Wall_Image_CommentCount + "", "Comments",activity));

        holder.okayCount.setText(spanString.changeStringSpanWall(data.get(position).wallPost_Images_Data
                .get(0).qst_Wall_Image_LikeCount + "", "Okay!",activity));

        holder.date.setText(fontsFamily.convertDate(data.get(position).wallPost_Date.toString(), activity));

        holder.userName.setText(data.get(position).wallPost_User_Name);

        //if(isScrolling==false)
        //imageLoader.DisplayImage(data.get(position).wallPost_User_Image, holder.userImage);



        final Vector<View> pages = new Vector<View>();
        //ViewPager
        /*CustomPagerAdapterForWall adap = new CustomPagerAdapterForWall(activity, activity, pages, data.get(position).wallPost_Images_Data);
        holder.ViewPager_Images.setAdapter(adap);
        holder.ViewPager_Images.setCurrentItem(pagePositon[position]);*/



        return convertView;
    }


    public class viewHolder
    {
        public  ViewPager ViewPager_Images ;
        public TextView questionName;
        public TextView userName;
        public TextView date;
        public TextView commentDount;
        public TextView okayCount;
        public ImageView userImage;
    }

}

0 个答案:

没有答案