我在RelativeLayout中添加了一个下拉菜单,但是他们没有显示图标,我该如何解决?
创建并显示菜单:
final PopupMenu popup = new PopupMenu(context, dots);
popup.getMenuInflater().inflate(R.menu.absences_menu, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(context, "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show();
return true;
}
});
dots.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
popup.show();
}
});
absences_menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/absences_remove"
android:title="Remove"
android:icon="@drawable/delete"/>
<item
android:id="@+id/two"
android:title="Two"/>
<item
android:id="@+id/three"
android:title="Three"/>
</menu>
结果:
问题:如何在RelativeLayout内的动态下拉菜单中添加图标?