I have downloaded kankan's wheel widget as an *.apk from here http://code.google.com/p/android-wheel/downloads/list and then converted it into *.jar file. I have attached this jar as a library to my project. Everything works fine. I can import all the classes from the library and use them in my project. However when I create the wheel object in my activity it works correctly but doesn't display correct background of the wheel. Instead it does show some random drawables from my project. What I'm doing wrong? where should I look to solve this problem? Here is my xml layout and DialogPreference class. Please help!!! Thanks.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="@drawable/layout_bg" >
<kankan.wheel.widget.WheelView
android:id="@+id/number"
android:layout_height="wrap_content"
android:layout_width="140dp" />
</LinearLayout>
NumberPickerPreference.java
import kankan.wheel.widget.OnWheelChangedListener;
import kankan.wheel.widget.WheelView;
import kankan.wheel.widget.adapters.NumericWheelAdapter;
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
public class NumberPickerPreference extends DialogPreference {
public NumberPickerPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.number_picker_layout);
}
@Override
protected View onCreateDialogView() {
view view = super.onCreateDialogView();
return view;
}
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
WheelView numberPicker = (WheelView)view.findViewById(R.id.number);
numberPicker.setViewAdapter(new NumericWheelAdapter(getContext(), 0, 99, "%02d"));
numberPicker.setCyclic(true);
numberPicker.setCurrentItem(17);
}
/**
* Adds changing listener for wheel that updates the wheel label
* @param wheel the wheel
* @param label the wheel label
*/
private void addChangingListener(final WheelView wheel, final String label) {
wheel.addChangingListener(new OnWheelChangedListener() {
public void onChanged(WheelView wheel, int oldValue, int newValue) {
//wheel.setLabel(newValue != 1 ? label + "s" : label);
}
});
}
}