2015-09-30 122 views
0

我找不到這個監聽器。它存在嗎? 例如,我設置的偵聽器點擊:如何爲ListView的子項目設置雙擊監聽器?

ListView listCategories = (ListView) findViewById(R.id.listCategories); 
ArrayAdapter<String> mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, titleCategories); 
listCategories.setAdapter(mAdapter); 
// Set listener: 
listCategories.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
    @Override 
    public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) { 
    // cod... 
    } 
} 

但對於雙擊?

+1

我建議你長按上雙擊。看看'OnItemLongClickListener' http://developer.android.com/reference/android/widget/AdapterView.OnItemLongClickListener.html –

+0

如Andrew所說,請通過android開發者頁面。 – dex

+0

這意味着這個void不存在。嗯,爲什麼不呢。可能會在將來... – Jack

回答

0
private void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
{ 
    DependencyObject obj = (DependencyObject)e.OriginalSource; 

    while (obj != null && obj != myListView) 
    { 
     if (obj.GetType() == typeof(ListViewItem)) 
     { 
      // Do something here on double click 
      MessageBox.Show("A ListViewItem was double clicked!"); 

      break; 
     } 
     obj = VisualTreeHelper.GetParent(obj); 
    } 
} 

Refernce:Get the item doubleclick event of listview

+0

我需要一個鱈魚爲Android) – Jack

相關問題