Reputation: 3575
I am making dynamically listview display below perticular item selected.can anybody suggest me how is it possible? I attested snapshot 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
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
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