我有一个Button
一个TextView
和一个ImageView
。当我单击按钮时,将出现rondom图像,TextView将显示图像名称。但我不需要它。 TextView必须显示以前的图像名称。我该怎么办?
public void onClick(View v) {
TypedArray ar = getResources().obtainTypedArray(R.array.logolar);
int len = ar.length();
int[] resIds = new int[len];
for (int i = 0; i < len; i++)
resIds[i] = ar.getResourceId(i, 0);
ar.recycle();
Random rand = new Random();
int rndInt = rand.nextInt(resIds.length) + 1;
try {
int resID = resIds[rndInt];
ImageView logolar = (ImageView)findViewById(R.id.logolar);
logolar.setImageResource(resID);
String lastImageName = getResources().getResourceEntryName(resID); //String lastImageName = getResources().getResourceName(resID); // bu da kullanilabilir
TextView logoismi = (TextView)findViewById(R.id.logoismi);
logoismi.setText(lastImageName);
clickeddata.add(logoismi.getText().toString()); //bir onceki logo verilerini depolama ozelligi
} catch (Exception e) {
e.printStackTrace();
}