使用项目';s的名字写在;如果;在Android中

使用项目';s的名字写在;如果;在Android中,android,arrays,spinner,Android,Arrays,Spinner,我在活动上有一个微调器: cmboopciones1=(微调器)findViewById(R.id.cmboopciones1); ArrayAdapter adapter1=ArrayAdapter.createFromResource(这个,R.array.exporal,android.R.layout.simple\u微调器\u项); adapter1.setDropDownViewResource(R.layout.multiline\u微调器\u下拉菜单\u项); cmbOpcion

我在活动上有一个
微调器

cmboopciones1=(微调器)findViewById(R.id.cmboopciones1);
ArrayAdapter adapter1=ArrayAdapter.createFromResource(这个,R.array.exporal,android.R.layout.simple\u微调器\u项);
adapter1.setDropDownViewResource(R.layout.multiline\u微调器\u下拉菜单\u项);
cmbOpciones1.设置适配器(适配器1);
这是数组XML:


上午7:00 9:00口述和口述
上午9:00 11:00口头和书面表达
我可以使用此代码将
微调器上的选定项目发送到另一个活动:

//BotonSeleccionar
BotonPasar1 = (Button)findViewById(R.id.VB1);
BotonPasar1.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
    //Preferences Materia 1

    SharedPreferences mypreferences1 = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor1 = mypreferences1.edit();
    editor1.putString("Culo", cmbOpciones1.getSelectedItem().toString());
    editor1.commit();
在另一个活动中,我有一个从
微调器接收数组项的代码:

//材料1
llegada1=(TextView)findViewById(R.id.tv1);
llegada2=(TextView)findViewById(R.id.tv2);
SharedReferences mypreferences=getApplicationContext().GetSharedReferences(“myPrefs”,Context.MODE\u PRIVATE);
SharedReferences mypreferences1=getApplicationContext().GetSharedReferences(“myPrefs”,Context.MODE\u PRIVATE);
字符串teamnamestring=mypreferences.getString(“Culo”,“no_name”);
String hola=mypreferences1.getString(“Culoq”,“no_name”);
llegada1.setText(teamnamestring);
llegada2.setText(hola);

假设我在ActivityA上有几个
微调器
,在ActivityB上有几个
文本视图
接收器如何按名称选择数组中的项?例如,如果我希望所有名为“1”的项都转到第一个
TextView
,而名为“3”的项转到“X”
TextView
,有没有办法用
if
语句来实现这一点?我想说清楚:我想在array XML示例中按项目名称调用项目

您要寻找的是以下方法,可以在所有Java字符串上调用:
equalsIgnoreCase(String)

带有if语句的示例:

    String test = "test";
    String test2 = "tEsT";
    String test3 = "tester"

    if(test.equalsIgnoreCase(test2) {
        // this will be true;
    }
    if(test3.equalsIgnoreCase(test2) {
        // this will be false;
    }