【问题标题】:How to disable ListView footer bounce effect如何禁用 ListView 页脚反弹效果
【发布时间】:2014-07-16 19:26:11
【问题描述】:

我有一个底部有页脚的 ListView,并且 ListView Items 有一个图像和一个文本视图。我的问题是,当我将列表快速滚动到底部时,即到最后一项时,它会显示页脚一段时间,然后它会拉下页脚并在底部显示列表的最后一个元素。但是每当我慢慢滚动时,它不会像快速滚动那样做。它就像弹跳效果一样,在快速滚动时列表会上升,然后返回显示底部的最后一项而不是页脚视图。 我有两张图片可以从中了解真实情况。

这是我快速滚动列表的第一张图片,起初我看到了页脚按钮

这是第二张图片,当滚动结束并且页脚按钮下降到最后一个项目的位置时。但是当我滚动缓慢时不会发生这种情况。所以请帮助我如何解决这个问题。提前致谢。

这是我的适配器代码

public class customAdapter extends ArrayAdapter<String> {

    Context context;
    Object user;
    ImageDownloader downloader;
    ArrayList<MyCustomAList> list;
    public customAdapter(Context context , int resid , String[] array, Object u, ArrayList<MyCustomAList> list) 
    {
        super(context,resid,array);
        this.context = context;
        this.user = u;
        this.downloader=new ImageDownloader();
        this.list=list;
    }

    @Override
    public View getView(int position, View view, ViewGroup arg2) {

        ViewHolder holder = null;
        LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        if(view == null)
        {
            view = mInflater.inflate(R.layout.customadapter_layout, null);
            holder = new ViewHolder();
            holder.title =(TextView) view.findViewById(R.id.textview);
            holder.userImage = (ImageView) view.findViewById(R.id.imageView1);
            view.setTag(holder);
        }else
        {
            holder = (ViewHolder) view.getTag();
        }
        holder.title.setText(list.get(position).text);
        downloader.download(list.get(position).url, holder.userImage);
        return view;
    }


    class ViewHolder 
    {
        ImageView userImage;
        TextView title;
    }

}

【问题讨论】:

    标签: android listview android-adapter


    【解决方案1】:

    像这样制作由ListViewFooter组成的Layout,我认为它会解决你的问题

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <!-- For header portion -->
    
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="12dp" >
    
            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Header"
                android:layout_gravity="center"
                android:textAppearance="?android:attr/textAppearanceLarge" />
    
        </FrameLayout>
    <!-- ListView -->
        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" >
        </ListView>
    <!-- Footer -->
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="Footer Button" />
    
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多