【问题标题】:Disable click for pending view of cwac-endless adapter禁用单击以查看 cwac-endless 适配器的未决视图
【发布时间】:2011-10-29 12:27:30
【问题描述】:

我正在使用cwac-endless 适配器,当我尝试加载更多结果时,我在禁用对待处理视图的点击时遇到了问题。

这是我用于扩展 EndlessAdapter 的自定义适配器的构造函数。 R.layout.pending 在加载时会膨胀。我想禁用单击此列表项。

public class MyEndlessAdapter extends EndlessAdapter{
    public MyEndlessAdapter(Context context, ListAdapter wrapped, int pendingResource) {
        super(context, wrapped, R.layout.pending);
    }
}

R.layout.pending xml 是 ...

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/white"
    android:textStyle="bold"
    android:gravity="center_vertical"
    android:paddingLeft="6dip"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:text="Getting more results..."
/>

我尝试的是为 TextView 提供 android:clickable="false",但它不起作用。

所以,我想知道是否有解决此问题的方法。

【问题讨论】:

    标签: android android-listview cwac-endless


    【解决方案1】:

    我的ListViewlv

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
                EndlessWordAdapter a = (EndlessWordAdapter)
                    parent.getAdapter();
                if(!(a.getItemViewType(position) == 
                    Adapter.IGNORE_ITEM_VIEW_TYPE)) {
                    // Do something
                } else {
                    // Ignore, pending view was clicked
                }
            }
        });
    

    禁用长按的方法相同。

    【讨论】:

    • 能否请您解释一下Adapter.IGNORE_ITEM_VIEW_TYPE
    • Read this。我实际上阅读了 cwac-endless 的 sources 并注意到 getItemViewType() 方法。看看它是如何工作的以及作者是如何评论它的。
    • 我不是 shure,但我认为 Adapter.IGNORE_ITEM_VIEW_TYPE 的意思是“此视图在 ListView 中,但它不是活动/启用/与其他项目一样工作”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多