0
我試圖隨機選擇15個ImageViews了21查看陣列,並希望將它們設置爲可點擊,則同樣需要給予TextView的陣列的ImageViews隨機選擇視圖陣列
這裏代碼..如何達到同樣的
public class HiddenObject {
Random _randomGenerator= new Random();
int hudDisplay[]={R.id.HUD_Text_Element1,R.id.HUD_Text_Element2,R.id.HUD_Text_Element3,
R.id.HUD_Text_Element4,R.id.HUD_Text_Element5,R.id.HUD_Text_Element6,
R.id.HUD_Text_Element7};
View[] _hudDisplay;
View[] _hiddenObjects;
int NO_OF_OBJECTS;
public HiddenObject(Context context,View v) {
// TODO Auto-generated constructor stub
View huddisplay= View.inflate(context, R.id.HUD_Display, null);
_hudDisplay=GetView.getViewArrays(huddisplay, R.id.HUD_Display);
NO_OF_OBJECTS=context.getResources().getInteger(R.integer.NO_OF_OBJECTS_AVAILABLE_PER_LEVEL);
_hiddenObjects= new View[NO_OF_OBJECTS];
random();
}
public void setHudDisplay()
{
}
public void random(){
for(int i=0;i<NO_OF_OBJECTS ;++i)
{
while(true)
{
Integer next = _randomGenerator.nextInt(GamePlayActivity._hiddenObjects.length);
_hiddenObjects[i]=GamePlayActivity._hiddenObjects[next];
Log.d("Print", "Image is " + _hiddenObjects[i].getContentDescription());
if(!_hiddenObjects[i].isClickable()){
_hiddenObjects[i].setClickable(true);
break;
}
}
}
}
}
我自己實現了...但問題是我需要不斷更新運行時的textview ... – user1201239 2012-03-07 06:26:03