【发布时间】:2015-06-21 09:12:45
【问题描述】:
我正在为某些操作使用外部 API。其中一种方法采用菜单(xml)项目列表,例如:
----.shape(R.menu.list).---
这是我的 R.menu.list 文件:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/share"
android:title="Share"
android:icon="@drawable/ic_share_grey600_18dp"/>
<item android:id="@+id/upload"
android:title="Upload"
android:icon="@drawable/ic_notifications_green"/>
</menu>
问题在于这个 R.menu.list 文件中的项目是未知的。它们可以变化。假设我有一个按钮,单击它时,我可能需要将 3 个项目传递给 .shape() 方法,有时我可能有 1 个左右的项目。我怎样才能做到这一点。
【问题讨论】:
标签: android xml android-xml android-xmlpullparser