答案 0 :(得分:0)
主要功能
String[] strings = {"Pilot", "Flight Attendant",
"Technical"};
Spinner mySpinner = (Spinner)findViewById(R.id.spinner);
mySpinner.setAdapter(new MyAdapter(NewMember.this, R.layout.row, strings));
我的适配器功能
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);
label =(TextView)row.findViewById(R.id.company);
label.setText(strings[position]);
if(label.getText().toString().contains("something"))
{
//do anything
}
return row;
}
}