Android 如何使用value/array.xml中的数据在转盘上设置侦听器?
我的文件array.xml中有12个图像,我想在单击旋转木马中的图像时设置一个侦听器WW。我想知道我选择了什么图像 my array.xmlAndroid 如何使用value/array.xml中的数据在转盘上设置侦听器?,android,image,drag-and-drop,Android,Image,Drag And Drop,我的文件array.xml中有12个图像,我想在单击旋转木马中的图像时设置一个侦听器WW。我想知道我选择了什么图像 my array.xml resources xmlns:android="http://schemas.android.com/apk/res/android"> <array name="entries"> <item>@drawable/pic1</item> <item>@drawable/pi
resources xmlns:android="http://schemas.android.com/apk/res/android">
<array name="entries">
<item>@drawable/pic1</item>
<item>@drawable/pic2</item>
.
.
</array>
resources xmlns:android=”http://schemas.android.com/apk/res/android">
@可抽出式/pic1
@可绘图/图片2
.
.
您可以设置图像的位置。 如何显示图像。 在gridview或LIstView中 你可以用这个
setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(HelloViewActivty.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
setOnItemClickListener(新的OnItemClickListener(){
public void onItemClick(AdapterView父视图、视图v、整型位置、长id){
Toast.makeText(helloviewactivity.this,“+位置,Toast.LENGTH_SHORT).show();
}
});
关于这一点的精彩教程在上,您的“旋转木马”应该有setOnItemClickListener或setOnItemSelectedListener方法。public void onItemClick(旋转木马父级、视图视图、int位置、长id){//int-drawableId=getResources().getIdentifier(“belier”、“drawable”、“com.carouseldemo.main”);Toast.makeText(MainActivity.this,“Position=“+Position,Toast.LENGTH_SHORT”).show();但我想在value/array.xml中的选定图像上创建一个侦听器