Since I am using chrisbanes push down to refresh library, I had to remove normal listview and replace it with the new one. After that though, long push on listview item doesn't work and always creashes. It seems that info returns always null, as he doesn't get information, what I am actually clicking, which is bad. Have been trying to fix it myself, but with no success.. Any help is appreciated.
xml layout:
<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" />
and the longpush code:
/** 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);
}
Also, I am using custom adapter, where I store all the information regarding every listitem row item, which I need to use in longpush.