我有两个单选按钮,它调用相同的微调器数组。所以基于单选按钮如何调用两个活动。我的代码如下:在这个我使用两个单选按钮,微调器和 xml 中的一个按钮
爪哇
Spinner selectcity;
RadioGroup rg = null;
RadioButton rb1,rb2;
Button searchbutton;
rg = (RadioGroup) findViewById(R.id.radioGroup);
rb1=(RadioButton)findViewById(R.id.seekers);
rb2=(RadioButton)findViewById(R.id.posting);
selectcity = (Spinner) findViewById(R.id.statespinners);
rb1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
selectcity=(Spinner)findViewById(R.id.statespinners);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
SearchCity.this, R.array.cities, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selectcity.setAdapter(adapter);
}
});
rb2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
selectcity=(Spinner)findViewById(R.id.statespinners);
ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(
SearchCity.this, R.array.area, android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selectcity.setAdapter(adapter1);
}
});
searchbutton=(Button)findViewById(R.id.statebutton);
searchbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//here i am strucked how to call two activities based on radio buttons selection
}
});
如何使用两个单选按钮更改并调用两个不同的活动。(A和B)。提前致谢。