我有很多Buttons,我想Identifier自动获取这些按钮。通常我这样设置id:
- 布局按钮1
- 布局按钮2
- 布局按钮3
- 布局按钮4
我得到了ButtonID:
getIdentifier(name, "id", getPackageName());
name是一个包含"LayoutButton" + number.toString(). 由于我想赋予Identifier名称更多意义,因此我想像这样命名按钮:
- 开始LayoutButton1
- 停止LayoutButton2
现在我只能得到idwith
getIdentifier("StartLayoutButton1", "id", getPackageName())
是否可以将名称与通配符匹配,例如:
getIdentifier("*LayoutButton1", "id", getPackageName())
其中*代表任何字符串。在id类内的R类中会有一个名为 的变量StartLayoutButton1。
现在我想获取包含LayoutButton1未知前缀的变量。