0
我有一個微調,但提示消息被忽略。我找不到原因。android:忽略提示
我的佈局:
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:prompt="@string/age"
android:drawSelectorOnTop="true"
android:background="@drawable/spinner_bg" />
我的代碼:
spinner = (Spinner) findViewById(R.id.spinner);
SpinnerAdapter adapter = new SpinnerAdapter(this, R.layout.spinner_item, getApplicationContext().getResources().getStringArray(R.array.spinnerArray));
spinner.setAdapter(adapter);
adapter.setDropDownViewResource(R.layout.spinner_item);
的SpinnerAdapter:
public class SpinnerAdapter extends ArrayAdapter<String>{
public SpinnerAdapter(Context context, int textViewResourceId,
String[] objects) {
super(context, textViewResourceId, objects);
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
Typeface externalFont=Typeface.createFromAsset(getContext().getAssets(), "fonts/PermanentMarker.ttf");
((TextView) v).setTypeface(externalFont);
return v;
}
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View v =super.getDropDownView(position, convertView, parent);
Typeface externalFont=Typeface.createFromAsset(getContext().getAssets(), "fonts/PermanentMarker.ttf");
((TextView) v).setTypeface(externalFont);
return v;
}
}
而且spinner_item的佈局:
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="38dp"
android:ellipsize="marquee"
android:gravity="center_vertical|left"
android:minHeight="38dp"
android:paddingLeft="5dp"
android:singleLine="true"
android:textSize="18sp" />
你有什麼想法嗎?
'age'是否存在於你的strings.xml中? – Barak
是的,我已經嘗試了幾個字符串 – g123k
你是否知道這個問題?是/它真的沒有工作,或者只是不在你期望的地方(像我理論化的那樣)? – Barak