在我的场景中,当我单击微调器时,值下拉列表将弹出,列表视图文本项与左对齐。现在我想要的是从列表项中选择后,当它设置为微调器值时,文本项应该右对齐。
无法找到解决方案。
以下是我的微调器代码
ArrayAdapter<String> adapter = new d4ValuesListAdapter(getActivity(),R.layout.spinner_dropdown_item, sVals);
dynamicSpinner.setAdapter(adapter);
dynamicSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
Log.v("item", (String) parent.getItemAtPosition(position));
dynamicSpinner.setGravity(Gravity.END);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
下面是我的适配器代码
public View getCustomView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
LayoutInflater inflater= ((FragmentChangeActivity) context).getLayoutInflater();
View row=inflater.inflate(R.layout.spinner_dropdown_item, parent, false);
TextView label=(TextView)row.findViewById(R.id.spinnervalues);
label.setText(DayOfWeek[position]);
sharedPrefrences =getActivity().getSharedPreferences(Constants.PREFERENCE_FILENAME,Activity.MODE_PRIVATE);
int spinneritem = sharedPrefrences.getInt(Constants.SPINNER_LISTITEM, -1);
if(spinneritem == position ){
label.setBackgroundColor(getResources().getColor(R.color.turquise_blue));
label.setTextColor(getResources().getColor(R.color.white_color));
}
return row;
}