将项目从 spinner1 更改为spinner2
. 好的,我正在创建一个翻译器。我有spinner1
一些语言和第二个使用相同语言的微调器。我从中选择一种“来自”语言,spinner1
并从中选择一种“至”语言spinner2
。好的,我想做的就是当我按下按钮时,它会交换选定的微调器项目。我不知道如何实现这一点。这是我的代码:
public class Example extends Activity {
ImageView MyChangeButton;
Spinner spinner1, spinner2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyChangeButton = (ImageView)findViewById(R.id.imageView1);
MyChangeButton.setOnClickListener(MyChangeButtonOnClickListener);
ArrayAdapter<CharSequence> adapter
= ArrayAdapter.createFromResource(this,
R.array.firstlanguage, android.R.layout.simple_spinner_item);
spinner1 = (Spinner) findViewById(R.id.spinner1);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter);
spinner2 = (Spinner) findViewById(R.id.spinner2);
adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(adapter);
}
private ImageView.OnClickListener MyChangeButtonOnClickListener = new ImageView.OnClickListener(){
public void onClick(View v) {
------>//Here the code that i want to do
}
};
};