Ich versuche, die Android Actionbar Spinner auf etwas, das wie die Google-Ströme Anwendung anpassen. Im Grunde sollte nur der "Untertitel" wiedergeben, was ich aus dem Kreisel wähle, während der "Titel" gleich bleibt. Ich verstehe, dass ein benutzerdefinierter Spinner erstellt werden muss und ich die getView()
und getDropDownView()
Methode überschreiben muss. Aber ich bin hier sehr verwirrt darüber, wie man diese Methoden richtig überschreibt. Kann mich bitte etwas in die richtige Richtung stoßen? Ich hoffe, ich habe meine Frage klargestellt.Actionbar Spinner Anpassung
the image screenshot http://androidcowboy.com/wp-content/uploads/2012/12/google-currents-3a.jpg
unten ist mein Code.
public class CustomSpinnerAdapter extends BaseAdapter {
private LayoutInflater inflater;
private final Context context;
private final String[] dropDown;
private final String mainText;
private final String subText;
public CustomSpinnerAdapter(Context context,
String mainText, String subText,String[] dropDown) {
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.mainText=mainText;
this.subText=subText;
this.context = context;
this.dropDown=dropDown;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View actionBarView = inflater.inflate(R.layout.custom_spinner, null);
TextView textView = (TextView) actionBarView
.findViewById(R.id.custom_spinner_textview);
textView.setText(mainText);
return actionBarView;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View dropDownView = inflater.inflate(R.layout.custom_spinner, null);
TextView dropDownTextView = (TextView) dropDownView
.findViewById(R.id.custom_spinner_dropdown_textview);
dropDownTextView.setText(dropDown[position]);
return dropDownView;
}
}
was ist Objectlayers? – ajay