Exemple #1
0
 @Override
 protected void configureTextView(TextView view) {
   super.configureTextView(view);
   if (currentItem == currentValue) {
     view.setTextColor(0xFF0000F0);
   }
   view.setTypeface(Typeface.SANS_SERIF);
 }
Exemple #2
0
  /**
   * Creates an wheelView (Dialog) so the user can set the date and time. Requires wheel_src library
   * project.
   *
   * @param Context to show in
   * @param Time to show in milliseconds
   * @return Dialog
   */
  public Dialog showDateDialog(Context in, long timeinms) {
    Dialog timeDialog = new Dialog(in);
    timeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    timeDialog.setContentView(R.layout.time2_layout);
    LayoutParams params = timeDialog.getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    timeDialog.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    boolean tf = false;
    tf = sp.getBoolean("prefs_time_24", true);

    int nhours = 23;
    int startH = 0;
    if (tf) {
      nhours = 23;
      startH = 0;
    } else {
      startH = 1;
      nhours = 12;
    }

    final WheelView hours = (WheelView) timeDialog.findViewById(R.id.hour);
    NumericWheelAdapter hourAdapter = new NumericWheelAdapter(TimeClock.this, startH, nhours);
    hourAdapter.setItemResource(R.layout.wheel_text_item);
    hourAdapter.setItemTextResource(R.id.text);
    hours.setViewAdapter(hourAdapter);

    final WheelView mins = (WheelView) timeDialog.findViewById(R.id.mins);
    NumericWheelAdapter minAdapter = new NumericWheelAdapter(TimeClock.this, 0, 59, "%02d");
    minAdapter.setItemResource(R.layout.wheel_text_item);
    minAdapter.setItemTextResource(R.id.text);
    mins.setViewAdapter(minAdapter);
    mins.setCyclic(true);

    final WheelView ampm = (WheelView) timeDialog.findViewById(R.id.ampm);
    ArrayWheelAdapter<String> ampmAdapter =
        new ArrayWheelAdapter<String>(TimeClock.this, new String[] {"AM", "PM"});
    ampmAdapter.setItemResource(R.layout.wheel_text_item);
    ampmAdapter.setItemTextResource(R.id.text);
    ampm.setViewAdapter(ampmAdapter);

    // set current time
    Calendar calendar = Calendar.getInstance(Locale.US);
    calendar.setTimeInMillis(timeinms);

    mins.setCurrentItem(calendar.get(Calendar.MINUTE));

    ampm.setCurrentItem(calendar.get(Calendar.AM_PM));
    if (tf) {
      hours.setCurrentItem(calendar.get(Calendar.HOUR_OF_DAY));
      ampm.setVisibility(View.GONE);
    } else {
      hours.setCurrentItem(calendar.get(Calendar.HOUR) - 1);
      ampm.setVisibility(View.VISIBLE);
    }

    final WheelView day = (WheelView) timeDialog.findViewById(R.id.day);
    day.setViewAdapter(new DayArrayAdapter(TimeClock.this, calendar));
    day.setCurrentItem(20);
    return timeDialog;
  }
  public TimeSelectManager(Context context) {
    this.context = context;
    view = LayoutInflater.from(context).inflate(R.layout.time_select_layout, null);
    view.findViewById(R.id.empty).setOnClickListener(this);
    view.findViewById(R.id.cancel).setOnClickListener(this);
    view.findViewById(R.id.sure).setOnClickListener(this);

    hours = (WheelView) view.findViewById(R.id.hour);
    NumericWheelAdapter hourAdapter = new NumericWheelAdapter(context, 0, 23, "%s时");
    hourAdapter.setItemResource(R.layout.wheel_text_item);
    hourAdapter.setItemTextResource(R.id.text);
    hours.setViewAdapter(hourAdapter);

    //	    final WheelView mins = (WheelView) view.findViewById(R.id.mins);
    //	    NumericWheelAdapter minAdapter = new NumericWheelAdapter(context, 0, 59, "%02d");
    //	    minAdapter.setItemResource(R.layout.wheel_text_item);
    //	    minAdapter.setItemTextResource(R.id.text);
    //	    mins.setViewAdapter(minAdapter);
    //	    mins.setCyclic(true);
    //
    //	    final WheelView ampm = (WheelView) view.findViewById(R.id.ampm);
    //	    ArrayWheelAdapter<String> ampmAdapter =
    //	        new ArrayWheelAdapter<String>(context, new String[] {"AM", "PM"});
    //	    ampmAdapter.setItemResource(R.layout.wheel_text_item);
    //	    ampmAdapter.setItemTextResource(R.id.text);
    //	    ampm.setViewAdapter(ampmAdapter);

    // set current time
    calendar = Calendar.getInstance(Locale.US);
    hours.setCurrentItem(calendar.get(Calendar.HOUR));
    //	    mins.setCurrentItem(calendar.get(Calendar.MINUTE));
    //	    ampm.setCurrentItem(calendar.get(Calendar.AM_PM));

    day = (WheelView) view.findViewById(R.id.day);
    day.setViewAdapter(new DayArrayAdapter(context, calendar));
  }