2015-11-07 106 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

相关问题