【问题标题】:onItemClick is conflict with onItemClickListener of SwipeListViewCallbackonItemClick 与 SwipeListViewCallback 的 onItemClickListener 冲突
【发布时间】:2015-10-17 11:08:11
【问题描述】:

我用过以下:

public class CategoryFragment extends Fragment implements SwipeListViewCallback {

private ListView category_linear;
//code...
category_linear.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {


                Intent ii = new Intent(context, otherscreen.class);
                startActivity(ii);

            }
        });

我也有 SwipeListViewCallback 的方法:

@Override
public void onItemClickListener(ListAdapter adapter, int position) {
    // TODO Auto-generated method stub


}

当我在列表视图项目上单击一次时,它不会打开其他活动。

当点击两次然后它就可以工作了。

我想一键打开列表视图项上的其他活动

【问题讨论】:

  • 为什么你同时使用 Listener ?只需使用category_linear.setOnItemClickListener(this); 并在onItemClickListener 方法中移动开始下一个活动相关代码
  • @ρяσѕρєяK 当我删除了 swipelistviewcallback 的监听器时,它显示错误Add unimplemented methods
  • 请重新阅读我的评论,我说的是替换您在setOnItemClickListener 中传递的匿名侦听器this
  • 当我写这个-category_linear.setOnItemClickListener(this);然后它显示错误The method setOnItemClickListener(AdapterView.OnItemClickListener) in the type AdapterView&lt;ListAdapter&gt; is not applicable for the arguments (CategoryFragment)

标签: android android-fragments android-intent android-listview swipe


【解决方案1】:

解决方案:

I have removed the `onItemClickListener` from SwipeListView class.

还去掉了swipe listview的方法。

 @Override
public void onItemClickListener(ListAdapter adapter, int position) {
    }

因此,当我从列表视图中单击项目时,它被称为单击侦听器上的列表视图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-29
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多