android 弹出网格菜单,在android中的recyclerView中显示弹出按钮的确...
as per my above comment可以使用Popup Menu
Android Popup Menu displays the menu below the anchor text if space is available otherwise above the anchor text. It disappears if you click outside the popup menu.
試試這個(gè)創(chuàng)建菜單文件
文件:poupup_menu.xml
android:id="@+id/one"
android:title="One"/>
android:id="@+id/two"
android:title="Two"/>
android:id="@+id/three"
android:title="Three"/>
比使用像這樣的創(chuàng)建彈出菜單
holder.img_chatroom_menu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//Creating the instance of PopupMenu
PopupMenu popup = new PopupMenu(MainActivity.this, button1);
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(MainActivity.this,"You Clicked : " + item.getTitle(),Toast.LENGTH_SHORT).show();
return true;
}
});
popup.show();//showing popup menu
}
});//closing the setOnClickListener method
總結(jié)
以上是生活随笔為你收集整理的android 弹出网格菜单,在android中的recyclerView中显示弹出按钮的确...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 第01组 Alpha冲刺(2/4)
- 下一篇: android icon命名规则,安卓手