私はアンドロイドのアクションバーのスピナーをgoogle currentアプリケーションのようなものにカスタマイズしようとしています。基本的に、 '字幕'だけが同じままで、スピナーから選択したものを '字幕'に反映する必要があります。カスタムスピナーを作成する必要があることを理解しており、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