android开发中,spinner下拉框的监听事件可以意图跳转吗 100
我是通过异步获得数据添加到下拉框中,但是点击选项无法意图跳转,我这样写出问题了还是什麽其他问题,求大神解答spinner.setOnItemSelectedListene...
我是通过异步获得数据添加到下拉框中,但是点击选项无法意图跳转,我这样写出问题了还是什麽其他问题,求大神解答
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapter, View view,
int position, long id) {
sInfo = spinner.getSelectedItem().toString();
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("login", sInfo);
intent.setClass(SpinnerActivity.this, listViewActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
} 展开
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapter, View view,
int position, long id) {
sInfo = spinner.getSelectedItem().toString();
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("login", sInfo);
intent.setClass(SpinnerActivity.this, listViewActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
} 展开
展开全部
spinner= (Spinner) findViewById(id.Myspiner);
// 建立数据源
String[] mItems = getResources().getStringArray(R.array.languages);
// 建立Adapter并且绑定数据源
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, mItems);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//绑定 Adapter到控件
spinner.setAdapter(adapter);
//首先确保spinner 已经初始化,把这里改一下
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
...
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询