I am trying to implement something similar to facebook/twitter feature which is showing a list of users when you add "@" sign. My problem is i don't know how to implement this kind of pop out or floating view . is it dialog or fragment ?
Asked
Active
Viewed 205 times
0
-
Autocomplete textview is your answer. check the link out http://stackoverflow.com/a/12795851/1061944 – Murtaza Khursheed Hussain May 06 '15 at 04:48
-
Thanks @MurtazaKhursheedHussain .i've checked ur link but i don't think i AutoCompleteTextView is sth i am looking for . Cuz it has preset data . pls see the photo i added in question . Thanks – Tixeon May 06 '15 at 04:59
-
You can always add data dynamically. It was an example to implement – Murtaza Khursheed Hussain May 06 '15 at 05:03
1 Answers
1
There is something known as ListPopUpWindow in android which could solve your problem. I have given a example below like how you can initiate it. Create your own listadapter and row xml file. Then pass it to the popup.setAdapter like how you handle the normal list in android.
private void initiatePopupWindow(View anchor) {
try {
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
ListPopupWindow popup = new ListPopupWindow(this);
popup.setAnchorView(anchor);
popup.setWidth((int) (display.getWidth()/(1.5)));
popup.setAdapter(new CustomAdapterForService(getApplicationContext(), R.layout.rowforservice, listCity));
popup.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long id3) {
//do what you need to do when you click on a popup list item
}
});
popup.show();
} catch (Exception e) {
e.printStackTrace();
}
}
Finally from where every you need to call it, call it with an Anchor. The anchor is the view, may be button or image or something from where you need to popup the list. Just like this.
initiatePopupWindow(yourOwnView)
This works for me. If any problem feel free to ask. Thanks.

Bullionist
- 2,070
- 3
- 25
- 42
-
Hi. I am using this code but item click listener is not working for me. – Death14Stroke Nov 25 '19 at 11:47