android 的spinner控件点击不能显示选中数据
android的spinner控件添加数据成功,为什么点击后不会再spinner上显示选中的数据呢,而且添加的onItemselectedListener监听也不起作用呢...
android 的spinner控件添加数据成功,为什么点击后不会再spinner上显示选中的数据呢,而且添加的onItemselectedListener监听也不起作用呢
more_feedback_spinner = (Spinner) findViewById(R.id.more_feedback_spinner);
adapter = new SimpleAdapter(this, sList, R.layout.list_parent,
new String[] { "catname" }, new int[] { R.id.list_parent });
more_feedback_spinner.setAdapter(adapter);
more_feedback_spinner.setAdapter(adapter); 展开
more_feedback_spinner = (Spinner) findViewById(R.id.more_feedback_spinner);
adapter = new SimpleAdapter(this, sList, R.layout.list_parent,
new String[] { "catname" }, new int[] { R.id.list_parent });
more_feedback_spinner.setAdapter(adapter);
more_feedback_spinner.setAdapter(adapter); 展开
1个回答
展开全部
这里是看不出什么问题的
你的这段处理是在
Activity的onCreate里面写的吗?
我这里的示例代码
String[] from = new String[] { "colorsData" };
int[] to = new int[] { android.R.id.text1 };
Spinner spinner = (Spinner) findViewById(R.id.spinner);
SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, android.R.layout.simple_spinner_item, from, to);
simpleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(simpleAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(
parent.getContext(),
"Selected Color:- "
+ parent.getItemAtPosition(position),
Toast.LENGTH_LONG).show();
}
});
}
你的这段处理是在
Activity的onCreate里面写的吗?
我这里的示例代码
String[] from = new String[] { "colorsData" };
int[] to = new int[] { android.R.id.text1 };
Spinner spinner = (Spinner) findViewById(R.id.spinner);
SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, android.R.layout.simple_spinner_item, from, to);
simpleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(simpleAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(
parent.getContext(),
"Selected Color:- "
+ parent.getItemAtPosition(position),
Toast.LENGTH_LONG).show();
}
});
}
追答
看你这样写的,应该是
spinner.setOnItemSelectedListener(self); 了吧
Activity implements AdapterView.OnItemSelectedListener 了吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |