Java 从微调器中选择并单击按钮以打开新活动
从微调器中选择时,如何使用按钮启动新活动? 我的密码是。。我已经搜索了很多,但没有任何效果,希望这里发生了什么:)Java 从微调器中选择并单击按钮以打开新活动,java,android,android-activity,spinner,Java,Android,Android Activity,Spinner,从微调器中选择时,如何使用按钮启动新活动? 我的密码是。。我已经搜索了很多,但没有任何效果,希望这里发生了什么:) 根据我的理解,当您从微调器中选择项目时,您希望打开一个具有按钮的活动。如果我的理解有误,请纠正我 将setOnItemSelectedListener设置为微调器并处理项目选择事件 spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
根据我的理解,当您从微调器中选择项目时,您希望打开一个具有按钮的活动。如果我的理解有误,请纠正我 将setOnItemSelectedListener设置为微调器并处理项目选择事件
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(position){
case 0:
//start activity on selection of any item you want, here I am assuming first item.
Intent intent = new Intent(YourCurrentActivity.this, ActivityWithButton.class);
startActivity(intent);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinner.setOnItemSelectedListener(新的AdapterView.OnItemSelectedListener(){
@凌驾
已选择公共视图(AdapterView父视图、视图视图、整型位置、长id){
开关(位置){
案例0:
//在选择您想要的任何项目时开始活动,这里我假设第一个项目。
意向意向=新意向(YourCurrentActivity.this、ActivityWithButton.class);
星触觉(意向);
打破
}
}
@凌驾
未选择公共无效(AdapterView父级){
}
});
终于!谢谢男人:)嗯。。。但是为什么它是从第二类而不是主要类开始的呢?我必须按“上一步”按钮返回微调器并再次选择,即使在我的清单中,我的启动器是主要的:/
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(position){
case 0:
//start activity on selection of any item you want, here I am assuming first item.
Intent intent = new Intent(YourCurrentActivity.this, ActivityWithButton.class);
startActivity(intent);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});