Vasant
Vasant

Reputation: 3575

How to display list below particular item selected?

I am making dynamically listview display below perticular item selected.can anybody suggest me how is it possible? I attested snapshot here.

enter image description here

I did code as below.

 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");
            }
        });

Your answer would be appreciated

Upvotes: 2

Views: 203

Answers (2)

Amit Kumar
Amit Kumar

Reputation: 208

try this

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();

Upvotes: 3

Itzik Samara
Itzik Samara

Reputation: 2288

Exmaple :

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.
    }
});

Upvotes: 0

Related Questions