2015-11-07 104 views
2

我正在動態listview顯示下面perticular項selected.can任何人建議我怎麼可能?我在這裏證實了快照。如何在選定的特定項目下方顯示列表?

enter image description here

我做了如下的代碼。

root.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       // im++; 

       final ListPopupWindow listPopupWindow = new ListPopupWindow(getActivity()); 
       ArrayList<String> a=new ArrayList<String>(); 
       a.add("a"); 
       a.add("b"); 
       listPopupWindow.setAdapter(new ArrayAdapter(
         getActivity(), 
         R.layout.raw_comment,a.size())); 
       listPopupWindow.setAnchorView(v); 
       listPopupWindow.show(); 
       //showAlertDialog(getActivity(), "List display 1"); 
      } 
     }); 

你的回答將不勝感激

回答

3

試試這個

final ListPopupWindow listPopupWindow = new ListPopupWindow(
        context); 
      listPopupWindow.setAdapter(new ArrayAdapter(
        context, 
        R.layout.list_row_layout, arrayOfValues)); 
      listPopupWindow.setAnchorView(your_view); 
      listPopupWindow.setWidth(300); 
      listPopupWindow.show(); 
+0

這不適合我。 – Vasant

+0

你面臨的問題是什麼? –

+0

我把我的代碼放在我的問題中。 – Vasant

0

〔實施例:

findViewById(R.id.btn).setOnTouchListener(new OnTouchListener() { 
    @Override 
    public boolean onTouch(View v, MotionEvent event) { 

     //use MotionEvent event : getX() and getY() will return your pressing 
     location in the button. 
    } 
}); 
+0

如何設置X'的y座標爲列表視圖? – Vasant

相關問題