我如何使用变量作为getResourceId(int index,int defValue)中的索引;

问题描述:

我使用以下代码来定义按钮背景:我如何使用变量作为getResourceId(int index,int defValue)中的索引;

TypedArray bottombuttons = res.obtainTypedArray(R.array.bottombuttons); 

button0.setBackgroundResource(bottombuttons .getResourceId(index, 1)); 

其中index是可变来自共享活动

int index = themePref.getInt("index", 1); 

是我不得不做出变化onResume()onCreate()

答案