As a follow up to this question, I have successfully implemented the WheelView with custom TextView (which has custom font for translation purposes).
adapter.setItemResource(R.layout.layout_item);
adapter.setItemTextResource(R.id.text);
The problem now is that the wheelview doesn’t highlight current Item as it should.
Adapter code:
/**
* 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);
}
}
In the above code, it does not go to configureTextView at all to highlight the item.
Original source of WheelView.
Okay, I figured it out. In case it helps anybody else, here’s the code: