很多时候我们会在下拉菜单中绑定一个值,但是 Spinner本身不提供这样的服务 于是在网上找了N久,终于找到一个简单易用的方案;废话不多说,直接上菜了 首先要定义一个Item类,有以下要注意的: 要重写它的.Tostring()函数,因为适配器在显示数据的时候,如果传入适配器的对象不是字符串的情况下,直接就使用对象.toString() public class CItem { private int ID; private String Value = ""; public
As the title of the post suggest in this tutorial we will see how to have spinner widget inside the toolbar in the previous series of tutorial we have seen many example on how to set up the android spinner widget and also we have seen how to have and
position = (Spinner)findViewById(R.id.position); String[] str = {"CEO","CFO","PM"}; ArrayAdapter aa = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item,str); position.setAdapter(aa);
上代码: spinner = (Spinner) findViewById(R.id.spinner); tv = (TextView) findViewById(R.id.tv); final ArrayList<String> list = new ArrayList<>(); list.add("不知道"); list.add("A"); list.add("B"); list.add("AB")