我正在尝试从 SimpleAdapter 获取数据,但我不知道它的语法。示例代码:
月份选择器.xml
<LinearLayout android:orientation="vertical">
<TextView
android:id="@+id/text"
android:text="Month of birth"
/>
<Spinner
android:id="@+id/spin_birthmonth"
android:entries="@array/birthmonth"
/>
</LinearLayout>
活动页面
public class SomeActivity extends Activity {
SimpleAdapter adapter;
ListView lv;
protected List<HashMap<String, String>> fillMaps;
protected String[] from;
protected int[] to;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lv = (ListView) findViewById(R.id.room_list_view);
fillMaps = new ArrayList<HashMap<String, String>>();
from = new String[] {"title", "spinner"};
to = new int[] {R.id.text, R.id.spin_birthmonth};
HashMap<String, String> map = new HashMap<String, String>();
map.put("title", "Your month of birth");
fillMaps.add(map);
adapter = new rSimpleAdapter(this, fillMaps, R.layout.month_selector, from, to);
lv.setAdapter(adapter);
}
}
我已经剪掉了一些东西以使其清晰易读,所以如果我遗漏了什么,请告诉我。我想做的是类似于...
Spinner month = adapter.getSpinner(R.id.spin_month);
但我不知道从适配器中获取微调器的语法是什么。如果可以解决问题,我可以将其设为自定义适配器。