2011-07-21 207 views
1

我在android中有一個listactivity。上下文菜單打開時,我按下我的列表視圖的項目。上下文菜單android

當我關閉這個上下文菜單,然後我回到按同一項目(其它項目都沒有問題)

如果我按到文本出現的問題,上下文菜單不公開,但如果我按白色區域,然後出現contextmenu。

¿什麼問題?

onCreate方法:

lv = getListView(); 

    lv.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 

      TextView text = (TextView) view.findViewById(R.id.label); 
      if (!text.getTag().toString().equals("-1")) 
      { 
       registerForContextMenu(text); 
       openContextMenu(text); 
      } 

     } 
     }); 

回答

1

如果你想爲你的ListView上下文菜單,來電registerForContextMenu()在您的活動onCreate(),傳遞ListViewHere is a sample project演示了這一點,包括顯示如何確定用戶長時間使用以彈出上下文菜單的用戶中的哪一行。