原本以為android:textSize
就可以改變字體大小,結果發現不行得自行設定。
XML
1 2 3 4 5 6 7 8
| <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinnertextlayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:textSize="30dip" />
|
Java
1 2 3 4 5 6 7
| Spinner spinner = (Spinner)findViewById(R.id.spinner); ArrayAdapter<CharSequence>list = ArrayAdapter.createFromResource( this, R.array.listitem, R.layout.spinnerlayout); list.setDropDownViewResource(R.layout.spinnerlayout); spinner.setAdapter(list);
|
另外介紹一下如何得到選擇的項目
1 2 3 4 5 6 7 8 9
| spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view,int position, long id) { string = String.valueOf(adapterView.getSelectedItem()); } @Override public void onNothingSelected(AdapterView<?> arg0) { } });
|