Hi I am creating small android application with cardlayout view. I have create card.Now I want to add overflow menu to my cardlayout. I can add image of overflow menu in my card layout. But how to open some overflow menu on click of it. Need some help. Thank you. I dont want to use any library because I already created UI for my cards. Just want to add overflow menu.
Asked
Active
Viewed 1,945 times
0
-
This should be reopened. It's a valid question for a very specific function: How to add an overflow menu to a card. I have an answer to this exact question here: http://stackoverflow.com/a/35166377/456568 – Aphex Feb 03 '16 at 00:28
2 Answers
3
Try Popup Menu ex. http://www.javatpoint.com/android-popup-menu-example
or PopupWindow ex. http://android-er.blogspot.in/2012/03/example-of-using-popupwindow.html
or ListPopupWindow ex.http://www.informit.com/articles/article.aspx?p=2078060&seqNum=4
all of them will work for you. But Popup menu is good as it works like optionsMenu for android.

MohK
- 1,873
- 1
- 18
- 29
0
ok i just got that project :) Don't know if it was the best way or not but i had done that :p I just simply created a listView in same layout and had set its visibility to "gone".
<LinearLayout
android:id="@+id/spinnerlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/linearLayout1"
android:layout_below="@+id/ll_upper"
android:layout_marginTop="15dp"
android:orientation="vertical"
android:visibility="gone">
<ListView
android:id="@+id/lv_menu"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/ll_upper"
android:visibility="visible" >
</ListView>
</LinearLayout>
and for this private String menuTitle[] = { "Facebook Login", "About", "Setting" };
then i set menuAdapter:
private class MenuAdapter extends BaseAdapter {
@Override
public int getCount() {
// TODO Auto-generated method stub
return menuTitle.length;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
LayoutInflater inf = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View v = inf.inflate(R.layout.item_menu, null);
((TextView) v.findViewById(R.id.tv_menuitem))
.setText(menuTitle[arg0]);
return v;
}
}
and finally hide and seek ;)
iv_menu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// lv_menu.setVisibility(View.VISIBLE);
// lv_menu.setCacheColorHint(color.transparent);
if (flag) {
list.setVisibility(View.VISIBLE);
lv_menu.setAdapter(new MenuAdapter());
flag = false;
}
else {
list.setVisibility(View.GONE);
lv_menu.setAdapter(new MenuAdapter());
flag = true;
}
}
});
lv_menu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
lv_menu.setVisibility(View.GONE);
//you code for doing Actions
}
});

kiturk3
- 549
- 10
- 30
-
Hi Kiturk thank you for quick replay. But I have already created card view. Just want overflow menu like in action bar with 3 dots. In same way s google showing in google play cards. – nilkash Dec 12 '14 at 04:54
-
ohh okok i have done before... lemme have a look and will get back to you soon – kiturk3 Dec 12 '14 at 05:04