微调器工作但是没有图像..我找不到问题!! 私人Spinner UnitSpinner; ArrayAdapter UnitArray; ArrayAdapter UnitArrayadapter; private static UnitConverter实例;
这是我的可绘制内容,假设显示在微调器中
int arr_images[] = { R.drawable.area, R.drawable.ds, R.drawable.feul,
R.drawable.legnth, R.drawable.temp, R.drawable.time, R.drawable.temp, R.drawable.time};
@SuppressLint("ShowToast")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
我的微调器在这里
UnitSpinner = (Spinner)findViewById(R.id.UnitSpinner);
UnitSpinner.setOnItemSelectedListener(this);
UnitArray=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item);
UnitArray.setDropDownViewResource(android.R.layout.simple_expandable_list_item_1);
UnitSpinner.setAdapter(UnitArray);
**微调器的项目**
UnitArray.add(getResources().getString(R.string.Temperature));
UnitArray.add(getResources().getString(R.string.Weight));
UnitArray.add(getResources().getString(R.string.Length));
UnitArray.add(getResources().getString(R.string.Power));
UnitArray.add(getResources().getString(R.string.Energy));
UnitArray.add(getResources().getString(R.string.Velocity));
UnitArray.add(getResources().getString(R.string.Area));
UnitArray.add(getResources().getString(R.string.Volume));
UnitArray.setNotifyOnChange(true);
UnitArrayadapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item);
UnitArrayadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
UnitArrayadapter.setNotifyOnChange(true);
}
public class MyAdapter extends ArrayAdapter<String>{
public MyAdapter(Context context, int textViewResourceId, String[] objects) {
super(context, textViewResourceId, objects);
}
@Override
public View getDropDownView(int position, View convertView,ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
public View getCustomView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater=getLayoutInflater();
View row=inflater.inflate(R.layout.row, parent, false);
row.findViewById(R.id.company);
row.findViewById(R.id.sub);
ImageView icon=(ImageView)row.findViewById(R.id.image);
icon.setImageResource(arr_images[position]);
return row;
}
}
public static UnitConverter getInstance(){
return instance;
}
public void onItemSelected(AdapterView<?> parent){
}
public void onNothingSelected(AdapterView<?> parent){
}
public void onItemSelected(AdapterView<?> parent, View v,
int position, long id){
if(v.getParent() == UnitSpinner){
}
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}