我想填充一个微调器下拉列表来显示调用后台线程的列表。我的代码无效。
ArrayAdapter <CharSequence> adapter = new ArrayAdapter <CharSequence> (this, android.R.layout.simple_spinner_item );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adapter.add(nameOfMethod(), items);
itemspin = (Spinner) findViewById(R.id.itemSpin);
itemspin.setAdapter(adapter);
有人能告诉我我做错了吗?
答案 0 :(得分:0)
spinner = (Spinner) findViewById(R.id.spinner);
// database handler
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
// Spinner Drop down elements
List<String> lables = db.getAllLabels();
// Creating adapter for spinner
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, lables);
// Drop down layout style - list view with radio button
dataAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// attaching data adapter to spinner
spinner.setAdapter(dataAdapter);
答案 1 :(得分:0)
试试这个
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items);
itemspin.setAdapter(adapter);