我從生產中的應用程序獲取信息,但是當我試圖重現問題時,我無法做到這一點。我正在尋找的是任何想法(因爲我被阻止)我怎樣才能重現錯誤。listview.pointToPosition在不應該提供INVALID值時
基本上我有一個列表視圖,工具欄,edittext和admob廣告活動。
我的listview由一個包含textview和一個imageview的relativealayout組成。
使用適配器,我將附加到文本視圖的OnLongClickListener啓動拖動操作。
爲了Listview本身,我添加了一個OnDragListener。
@TargetApi(11)
public class myDragEventListener implements View.OnDragListener {
// This is the method that the system calls when it dispatches a drag event to the
// listener.
public boolean onDrag(View v, DragEvent event) {
// Defines a variable to store the action type for the incoming event
final int action = event.getAction();
// Handles each of the expected events
switch(action) {
case DragEvent.ACTION_DRAG_STARTED:
return true;
case DragEvent.ACTION_DROP:
//We detect which is the item where the drop happened on.
int itemPosition = listShop.pointToPosition((int)event.getX(), (int)event.getY());
// An unknown action type was received.
default:
return true;
}
}
}
所以,基本上我們從列表視圖項開始拖動textview,拖放在列表視圖本身結束。
此代碼正常工作,但我從生產報告收到有時itemPosition的值爲-1。爲了避免例外,我可以添加一個簡單的檢查,但我擔心用戶體驗。
因此,我想避免的是應用程序沒有正確響應的不良用戶體驗,而且我們知道這是由於報告而發生的。問題是我們無法複製。
試圖重現這個錯誤,我們嘗試:
- Longclick上的TextView和ImageView的下降。 (提供正確itemPosition)
- Longclick上textivew和降列表視圖(拖聽者不叫)
- Longclick上textivew和下降外,在列表視圖的邊緣(工作正常)。
有人對這個「-1」如何被複制的建議嗎?理論上它不應該發生....是下降(無論發起的拖動是什麼)激活OnDragListener,這意味着下降發生的位置是列表視圖的位置。在一個不正確的位置,如何在ListView中調用DragListener?
任何想法可能發生什麼?