我使用these library时遇到WheelView问题。我创建了一个Dialog,我想在其中放置一个WheelView,但我无法更改当前项目,我无法确定问题所在,代码:
public class SpeedDialog extends AlertDialog implements android.view.View.OnClickListener{
private Activity activity;
TextView textView;
int current = 50;
public SpeedDialog(Activity activity, int theme) {
super(activity, theme);
this.activity = activity;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.speed_dialog);
WheelView wheelView = (WheelView)findViewById(R.id.wheel_speed);
textView = (TextView) findViewById(R.id.current_value);
Button button = (Button) findViewById(R.id.apply);
button.setOnClickListener(this);
wheelView.setViewAdapter(new NumericWheelAdapter(activity, 50, 200, "%1.2f", 100));
wheelView.addChangingListener(new OnWheelChangedListener() {
@Override
public void onChanged(WheelView wheel, int oldValue, int newValue) {
setCurrent(newValue);
textView.setText(String.valueOf(newValue));
}
});
wheelView.setCurrentItem(getcurrent());
}
public Integer getcurrent() {
return current;
}
public void setCurrent(int current) {
this.current = current;
}
@Override
public void onClick(View v) {
switch (v.getid()) {
case R.id.apply:
dismiss();
break;
}
}
}
答案 0 :(得分:0)
使用共享偏好解决了保存和加载值