移除ListView底部点击监听器。

14

列表视图页脚

RelativeLayout listFooterView = (RelativeLayout) inflater.inflate(
            R.layout.my_footer_layout, null);
getListView().addFooterView(listFooterView);

列表视图的点击监听器

listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                int position, long id) {
            // TODO Auto-generated method stub
            Intent i = new Intent(getApplicationContext(),
                    Abc.class);
            startActivity(i);

        }
    });

当我点击页脚视图时,点击监听器仍然起作用。如何禁用页脚的点击事件。

提前致谢。

1个回答

37

尝试使用以下功能添加页脚:addFooterView(View v, Object data, boolean isSelectable)

可以尝试类似以下的代码:

RelativeLayout listFooterView = (RelativeLayout) inflater.inflate(
            R.layout.my_footer_layout, null);
getListView().addFooterView(listFooterView,null,false);

我添加了页脚视图后,如何切换该行为?到目前为止,我找到的唯一方法是删除并重新添加页脚视图(更改true/false参数),但我不喜欢这种解决方案。 - Bitcoin Cash - ADA enthusiast

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接