使用此代码
public class MainActivity extends Activity {
Button MyTranslateButton;
private int image[];
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image =new int[]{R.drawable.adv_book,R.drawable.background,R.drawable.bid_active,R.drawable.break_finish};
MyTranslateButton = (Button)findViewById(R.id.TranslateButton);
MyTranslateButton.setOnClickListener(MyTranslateButtonOnClickListener);
}
private Button.OnClickListener MyTranslateButtonOnClickListener
= new Button.OnClickListener(){
@SuppressWarnings("null")
public void onClick(View v) {
for(int i=0 ; i < image.length ; i++){
String names[]=new String[image.length];
String name=getResources().getResourceEntryName(image[i]);
Log.i("Image Names is ",name);
names[i]=getResources().getResourceEntryName(image[i]);
}
}
};
}