0
作爲this question的後續操作,我已成功實現帶有自定義TextView(具有用於翻譯目的的自定義字體)的WheelView。現在帶有自定義TextView的WheelView不會突出顯示currentItem
adapter.setItemResource(R.layout.layout_item);
adapter.setItemTextResource(R.id.text);
的問題是,wheelview並不突出當前的項目,因爲它應該。
適配器代碼:
/**
* Adapter for string based wheel. Highlights the current value.
*/
private class DateArrayAdapter extends ArrayWheelAdapter<String> {
// Index of current item
int currentItem;
// Index of item to be highlighted
int currentValue;
/**
* Constructor
*/
public DateArrayAdapter(Context context, String[] items, int current) {
super(context, items);
this.currentValue = current;
setTextSize(16);
}
@Override
protected void configureTextView(TextView view) {
super.configureTextView(view);
if (currentItem == currentValue) {
view.setTextColor(getResources().getColor(R.color.holo_blue));
}
view.setTypeface(Typeface.SANS_SERIF);
view.setTextSize(18);
}
@Override
public View getItem(int index, View cachedView, ViewGroup parent) {
currentItem = index;
return super.getItem(index, cachedView, parent);
}
}
在上面的代碼,它不會去configureTextView
不惜一切來選擇項目。 WheelView的