我有一个从活动动态创建的微调器。我想从服务器中根据数据库选择一个值,所以我正在这样做
String[] items = { "Credit Card", "Cash"};
final Spinner TP = new Spinner(this);
TP.setId(20);
TP.setPadding(8,8,8,8);
TP.setBackgroundResource(R.drawable.text_bg);
TourExpenseListDetailRow.addView(TP);// add the column to the table row here
LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams)TP.getLayoutParams();
params1.setMargins(0, 0, 0, 0); //substitute parameters for left, top, right, bottom
TP.setLayoutParams(params1);
//Selecting value as per database for testing I am selecting Position 1
TP.setSelection(1);
ArrayAdapter aa = new ArrayAdapter(this, R.layout.spinner_item, items);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
TP.setAdapter(aa);
但我的问题是我的价值永远不会被选中