Spinner
我在布局时遇到问题。我的实际要求是放置Spinner
一次,在布局的顶部。
我得到的这个输出:
我有相对布局
<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:entries="@array/string_array"
android:prompt="@string/spinner_msg"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/notesTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
</TextView>`
MyActivity
类由ListActivity
这里的onCreate
方法扩展
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listView=getListView();
listView.setOnItemClickListener(listener);
spinner1=(Spinner)findViewById(R.id.spinner1);
getDetailsCursor();
String[] from = new String[] {"db_column"};
int[] to = new int[] { R.id.notesTextView};
curAdapter=new SimpleCursorAdapter(MyActivity.this, R.layout.mylist, null, from, to);
setListAdapter(curAdapter);
registerForContextMenu(listView);
}`