0

how to add option menu in listview like this screenshot. it's taken from GooglePlay
anybody have sample code or reference link like this screenshot



enter image description here

Muhammad Waleed
  • 2,517
  • 4
  • 27
  • 75
  • please explain.. why you down vote my question – Muhammad Waleed Oct 01 '15 at 11:44
  • It's just a [`PopupMenu`](http://developer.android.com/guide/topics/ui/menus.html#PopupMenu) anchored to a simple `ImageView` (or `ImageButton`). There's also a compat version in the v7 support library. – MH. Oct 01 '15 at 11:47
  • @MH. how we can add in cardview...?? – Muhammad Waleed Oct 01 '15 at 11:50
  • Refer this may solve your problem : http://stackoverflow.com/a/16427480 and https://github.com/codepath/android_guides/wiki/Menus-and-Popups and http://stackoverflow.com/a/22311108 – Janak Oct 01 '15 at 12:05

3 Answers3

1

If you want to save time you can use this cardview library by gabrielemariotti. It has build in card exactly what you wanted, so you can use it directly in your code.

Just add gradle dependencies:

dependencies {
    compile 'com.github.gabrielemariotti.cards:cardslib-core:2.1.0'
}

The rest you can follow from the documentation.

Ganesh Pandey
  • 5,216
  • 1
  • 33
  • 39
1

One simple and quick solution: Add image to your List item and perform on click event on it:

import android.support.v7.widget.PopupMenu;




PopupMenu popup = new PopupMenu(mContext, view);
popup.getMenu().add("AAA");
popup.getMenu().add("BBB");
popup.getMenu().add("CCC");
popup.getMenu().add("CCC");
popup.show();
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
    //perform action here
    });
}
Akshay
  • 6,029
  • 7
  • 40
  • 59
0

public class Homepage extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_homepage);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater=getMenuInflater();
    inflater.inflate(R.menu.option,menu);
    return true;
}

}

Kusum
  • 1