Android存储可绘制阵列

Android存储可绘制阵列,android,spinner,drawable,arrays,Android,Spinner,Drawable,Arrays,我目前正在尝试访问并使用一个图像来代替我正在使用的微调器中的文本。 如果我专门使用文本而不是绘图,那么下面的代码是有效的 我以前提到过这个问题: 希望解决我的问题,但我无法准确地找出我的错误。我似乎不断地得到: Error: No resource found that matches the given name (at '^index_1' with value '@drawable/ic_launcher.png') 等等,对于每个图像。每个可绘制文件都存在并位于适当的位置,代码显然

我目前正在尝试访问并使用一个图像来代替我正在使用的微调器中的文本。 如果我专门使用文本而不是绘图,那么下面的代码是有效的

我以前提到过这个问题:

希望解决我的问题,但我无法准确地找出我的错误。我似乎不断地得到:

Error: No resource found that matches the given name (at '^index_1' with value '@drawable/ic_launcher.png')  
等等,对于每个图像。每个可绘制文件都存在并位于适当的位置,代码显然超出了我的理解范围

<string-array name="rating_array">
        <item>N/A</item>
        <item>@drawable/ic_launcher.png</item>
        <item>@drawable/smile.png</item>
        <item>@drawable/stale.png</item>
        <item>@drawable/sad.png</item>
        <item>@drawable/angry.png</item>
    </string-array>
如有错误:

错误:未找到与给定名称匹配的资源(位于“^index\u 1” 值为“@drawable/ic_launcher.png”)

因为您当前正在通过
字符串数组中的可绘制名称传递可绘制图像扩展(.png)。因此,您需要删除在
字符串数组中使用的可绘制名称的文件扩展名(.png)
将其更改为:

<string-array name="rating_array">
        <item>N/A</item>
        <item>@drawable/ic_launcher</item>
        <item>@drawable/smile</item>
        <item>@drawable/stale</item>
        <item>@drawable/sad</item>
        <item>@drawable/angry</item>
    </string-array>

不适用
@牵引式/集成电路发射器
@拖拉/微笑
@可抽出/陈旧
@可提取/悲伤
@拖拉的/愤怒的

发布您的代码以访问上述内容
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Spinner;

public class MainActivity extends Activity {

    private Spinner spinbutton1, spinbutton2, spinbutton3;





    @Override
    protected void onCreate(Bundle savedInstanceState) {        
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);




    }

    public void addListenerOnSpinnerItemSelection(){
        spinbutton1 = (Spinner) findViewById(R.id.spinbutton1);
            spinbutton1.setOnItemSelectedListener(new CustomOnItemSelectedListener());
        spinbutton2 = (Spinner) findViewById(R.id.spinbutton2);
            spinbutton2.setOnItemSelectedListener(new CustomOnItemSelectedListener());
        spinbutton3 = (Spinner) findViewById(R.id.spinbutton3);
            spinbutton3.setOnItemSelectedListener(new CustomOnItemSelectedListener());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }




}
<string-array name="rating_array">
        <item>N/A</item>
        <item>@drawable/ic_launcher</item>
        <item>@drawable/smile</item>
        <item>@drawable/stale</item>
        <item>@drawable/sad</item>
        <item>@drawable/angry</item>
    </string-array>