长按不起作用(使用下推刷新库)

Elv*_*ven 0 android push

由于我使用chrisbanes 按下来刷新库,我不得不删除正常的listview并用新的替换它.在那之后,长时间推送listview项目不起作用,并始终刷新.似乎信息返回总是为null,因为他没有获取信息,我实际点击的是什么,这是不好的.一直试图自己解决它,但没有成功..任何帮助表示赞赏.

xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >


<ProgressBar
    android:id="@+id/loadingbar"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:visibility="gone" />

<TextView
    android:id="@+id/loading_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="Loading... Hang in there!"
    android:visibility="gone" />

 <com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="@+id/animelist"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
Run Code Online (Sandbox Code Playgroud)

和longpush代码:

/** This will be invoked when an item in the listview is long pressed */
    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

        Log.d("readInfo", "LONG CLICK!!"); 
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        Log.d("prereadlongclickinfo", "test"); 
        favorites = readFavoritesList();
        parsedFavorites = parse(favorites);
        Log.d("readlongclickinfo", "test2"); 
        Log.d("readlongclickinfo", "test: "); 

        /*boolean favorited = false;
        for(String favorite : parsedFavorites){
            if(favorite.equals(anime_list.get(info.position).seriaal)){
                menu.add(0, 2, 1, R.string.removeFavorite);
                favorited = true;
                break;
            }
        }
        if(!favorited) {
            menu.add(0, 1, 1, R.string.addFavorite);
            menu.add(0, 3, 1, R.string.addBlacklist);
        }*/
        menu.add(0, 4, 1, R.string.openWebpage);
        super.onCreateContextMenu(menu, v, menuInfo);
    }
Run Code Online (Sandbox Code Playgroud)

此外,我正在使用自定义适配器,我存储有关每个listitem行项的所有信息,我需要在longpush中使用.

Elv*_*ven 5

很遗憾没人帮忙.

好吧,经过几个小时的研究,我找到了解决方案,这简直太容易了.我希望它能引导将来遇到同样问题的人.

基本上,我做了空ListView,并给了我pushDownListView所具有的所有值.之后,我将其注册为创建功能.几行代码:

pullToRefreshView = (PullToRefreshListView) findViewById(R.id.animelist);
        ListView lv1 = pullToRefreshView.getRefreshableView();

    registerForContextMenu(lv1);

    lv1.setAdapter(anime_list_adapter);

    registerForContextMenu(lv1);
Run Code Online (Sandbox Code Playgroud)