2014-01-07 32 views
0

如何使AdapterView.OnItemClickListener()的工作,當AdapterView.OnItemClickListener()不工作

... activity implements View.OnLongClickListener, View.OnClickListener, 
DragDropPresenter, 
View.OnTouchListener { ... } 

,我有

public void onClick(View v) { 
    // TODO Auto-generated method stub 

} 

處理點擊? 想法是通過長時間點擊來激活拖放操作,並且只需短按即可使用OnItemClickListener方法。它甚至有可能嗎?

回答

0

我克服了通過分配每一個小區的標籤處理短點擊,然後讀取標籤用簡單的問題onClick監聽器:

public void onClick(View v) { 
    Integer position = (Integer)v.getTag(); 
    if (position = ...){ do some stuff } 
} 
0

你的問題有點簡單,但我希望下面的例子中會有所幫助:

public class MainActivity extends Activity implements OnClickListener, OnItemClickListener, OnItemLongClickListener { 

.... 
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 

    ..... 
    listView.setAdapter(adapter); 
    listView.setOnItemLongClickListener(this); 
    listView.setOnItemClickListener(this); 
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); 
    ..... 

} 

@Override 
public boolean onItemLongClick (AdapterView<?> parent, View item, int position, long id) { 
.... 
}