Android List中的Google Now样式三点菜单

时间:2014-01-26 00:15:54

标签: android listview google-now

我模仿Google Now卡的样式,现在我希望每张卡上都有三点菜单,以显示此列表项可能提供的更多高级选项。

不幸的是,我不知道他们是如何做到的。它似乎与onOptionsItemSelected类似。

Screenshot

有什么想法吗?

2 个答案:

答案 0 :(得分:5)

我建议你使用这个CardLib项目:https://github.com/gabrielemariotti/cardslib

它在提供卡主题UI方面非常全面,几乎可以满足所有功能。

答案 1 :(得分:1)

一个简单的imageView会做。在listview列表布局中放置一个imageview(3点菜单图标),然后在bindView或任何其他相关方法中调用它onClickListener

例如,您可以使用SimpleCursorAdapter并覆盖它的bindView()方法。

@Override
public void bindView(View view, Context context, Cursor cursor) {
ImageView overflowMenu = (ImageView) view.findViewById(R.id.yourId);
overflowMenu.setOnClickListener(new OnClickListener(){

      @Override
      public void onClick(View v) {
      //Get position of the item clicked
      final int position = getListView().getPositionForView((LinearLayout)v.getParent());
      //Get the cursor of the item clicked
      final Cursor c = (Cursor) getListView().getItemAtPosition(position);
      }
}