0
我的問題很簡單。我有一個ListView裏面的SwipeRefreshLayout,我想處理ListView的onItemLongClick事件。但它不會識別它被長時間點擊,我不知道什麼是錯的?ListView裏面SwipeRefreshLayout無法處理onItemLongClick事件
這是我的XML:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hapticFeedbackEnabled="true"
android:longClickable="true" >
<ListView
android:id="@+id/list_timeline"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent"
android:divider="@null"
android:hapticFeedbackEnabled="true"
android:listSelector="@android:color/transparent"
android:longClickable="true"
android:scrollbarStyle="outsideOverlay"
android:soundEffectsEnabled="true" >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
,這裏是我的Java文件
listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) {
Log.v(TAG, "Content Clicked!");
postContentToWall(m1Result.get(pos));
return true;
}
});
什麼意思不工作?你有什麼錯誤嗎? – Apurva 2015-02-24 16:25:17
沒有錯誤,但沒有跡象表明它被長時間打開。 Log從未被調用,並且postContentToWall函數從未發生過。 – kenlz 2015-02-24 16:39:02
在'onItemClick()'裏面加上'toast'消息並檢查它是否工作! – Apurva 2015-02-24 16:43:18