【发布时间】:2016-09-07 19:40:14
【问题描述】:
我有这个布局
spinnertipocombustible.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textview"
android:layout_height="30dip"
android:layout_width="wrap_content"
android:textSize="50dip"
android:textColor="#ccddaa"
/>
</LinearLayout>
在对话框片段中我有这段代码
listado=DM.RegresaTiposCombustible();
adapter= new TiposCombustibleAdapter(getActivity(),R.layout.spinnertipocombustible,listado);
adapter.setDropDownViewResource(R.layout.spinnertipocombustible);
spinner.setAdapter(adapter);
在下一张图片中,您可以看到文字大小如果我更改则不会更改 spinnertipocombustible.xml 中的这一行
android:textSize="50dip"
这是我的适配器..
public class TiposCombustibleAdapter extends ArrayAdapter<TipoCombustible>{
private Context context;
private List<TipoCombustible> tipoCombustibles;
public TiposCombustibleAdapter(Context context, int textViewResourceId, List<TipoCombustible> tiposCombustible){
super(context,textViewResourceId,tiposCombustible);
this.context=context;
this.tipoCombustibles=tiposCombustible;
}
public int getCount(){
return tipoCombustibles.size();
}
public TipoCombustible getItem(int position){
return tipoCombustibles.get(position);
}
public long getItemId(int position){
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// I created a dynamic TextView here, but you can reference your own custom layout for each spinner item
TextView label = new TextView(context);
label.setTextColor(Color.BLACK);
// Then you can get the current item using the values array (Users array) and the current position
// You can NOW reference each method you has created in your bean object (User class)
label.setText(tipoCombustibles.get(position).getDescripcion());
// And finally return your dynamic (or custom) view for each spinner item
return label;
}
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
TextView label = new TextView(context);
label.setTextColor(Color.BLACK);
label.setText(tipoCombustibles.get(position).getDescripcion());
return label;
}
}
【问题讨论】:
标签: android android-layout layout spinner android-spinner