我想自定義android動作欄微調到谷歌當前的應用程序的東西。基本上,只有'副標題'應該反映我從旋轉器中選擇的內容,而'標題'保持不變。我知道自定義微調器需要被創建,我必須重寫getView()
和getDropDownView()
方法。但我很困惑這裏如何正確地重寫這些方法。有些人可以推動我朝着正確的方向前進。我希望我明確提出了我的問題。動作欄微調器定製
the image screenshot http://androidcowboy.com/wp-content/uploads/2012/12/google-currents-3a.jpg
下面給出的是我的代碼。
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;
}
}
是什麼Objectlayers? – ajay 2014-09-18 07:28:35