ViewGroup clearFocus - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ViewGroup clearFocus method.

This code example shows how to use the following methods:clearDisappearingChildren, clearFocus, clearCache, clearFormData, clearHistory
This code example shows how to use the following methods:clearFocus, getDayOfMonth, getMonth, getYear
        tryNotifyDateTimeSet(); 
    } 
 
    private void tryNotifyDateTimeSet() { 
        if (mCallBack != null) {
            mDatePicker.clearFocus();
            mCallBack.onDateTimeSet(mDatePicker, mTimePicker, mDatePicker.getYear(),
                    mDatePicker.getMonth(), mDatePicker.getDayOfMonth(),
                    mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
        } 
    } 
 
    @Override 
    protected void onStop() { 
        if (Build.VERSION.SDK_INT >= 16) {
            // The default behavior of dialogs changed in JellyBean and onwards. 
            // Dismissing a dialog (by pressing back for example) 
            // applies the chosen date. This code is added here so that the custom 
            // pickers behave the same as the internal DatePickerDialog. 
            tryNotifyDateTimeSet(); 
7
CodeRank
This code example shows how to use the following methods:clearFocus, getDayOfMonth, getMonth, getYear
			this.setButton(DialogInterface.BUTTON_POSITIVE, getContext().getText(android.R.string.ok), new DialogInterface.OnClickListener()
			{ 
				@Override 
				public void onClick(DialogInterface dialog, int which)
				{ 
					picker.clearFocus(); // focus must be cleared so the value change listener is called
					callback.onDateSet(picker, picker.getYear(), picker.getMonth(), picker.getDayOfMonth());
				} 
			}); 
		} 
		catch(Exception e)
		{ 
			// reflection probably failed 
		} 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:clearFocus, getValue
        mNumberPicker.setValue(number);
    } 
 
    public void onClick(DialogInterface dialog, int which) {
        if (mCallback != null) {
            mNumberPicker.clearFocus();
            mCallback.onNumberSet(mDialogId, mNumberPicker.getValue());
            dialog.dismiss();
        } 
    } 
 
    @Override 
    public Bundle onSaveInstanceState() {
        Bundle state = super.onSaveInstanceState();
        state.putInt(NUMBER, mNumberPicker.getValue());
        return state;
    } 
 
    @Override 
    public void onRestoreInstanceState(Bundle savedInstanceState) {
8
CodeRank
This code example shows how to use the following methods:clearFocus, getDayOfMonth, getMonth, getYear
        tryNotifyDateTimeSet(); 
    } 
 
    private void tryNotifyDateTimeSet() { 
        if (mCallBack != null) {
            mDatePicker.clearFocus();
            mCallBack.onDateTimeSet(mDatePicker, mTimePicker, mDatePicker.getYear(),
                    mDatePicker.getMonth(), mDatePicker.getDayOfMonth(),
                    mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
        } 
    } 
 
    @Override 
    protected void onStop() { 
        if (Build.VERSION.SDK_INT >= 16) {
            tryNotifyDateTimeSet(); 
        } 
        super.onStop(); 
    } 
 
7
CodeRank
This code example shows how to use the following methods:clearFocus, getDayOfMonth, getMonth, getYear
    } 
 
    @Override 
    public void onClick(DialogInterface dialog, int which) {
        super.onClick(dialog, which);
        mDatePicker.clearFocus();
        onDateChanged(mDatePicker, mDatePicker.getYear(), mDatePicker.getMonth(),
                mDatePicker.getDayOfMonth());
        onDialogClosed(which == DialogInterface.BUTTON1);
    } 
 
    @Override 
    protected void onDialogClosed(boolean positiveResult) {
        if (!positiveResult) {
            sharedPreferences(); 
        } 
 
        super.onDialogClosed(positiveResult);
    } 
 
7
CodeRank
This code example shows how to use the following methods:requestFocus, clearFocus, hasFocus
 
    @Test 
    public void clearFocus_shouldRecursivelyClearTheFocusOfAllChildren() throws Exception { 
        child3a.requestFocus();
 
        root.clearFocus();
 
        assertFalse(child3a.hasFocus());
        assertFalse(child3.hasFocus());
        assertFalse(root.hasFocus());
 
        root.requestFocus();
        root.clearFocus();
        assertFalse(root.hasFocus());
    } 
 
    @Test 
    public void dump_shouldDumpStructure() throws Exception { 
        child3.setId(R.id.snippet_text);
 
7
CodeRank
This code example shows how to use the following methods:clearFocus, getDayOfMonth, getMonth, getYear
    } 
     
    @Override 
    public void onClick(DialogInterface dialog, int which) {
        if (mCallBack != null) {
            mDatePicker.clearFocus();
            mCallBack.onDateSet(mDatePicker, mDatePicker.getYear(), mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
        } 
    } 
     
    @Override 
    public void onDateChanged(DatePicker view, int year,int month, int day) {
        boolean color = true;
		if (isDateAfter(view)) {
			textViewVisible(); 
			Calendar mCalendar = Calendar.getInstance();
			mCalendar.setFirstDayOfWeek(Calendar.MONDAY);
			if (color) {
				view.init(mCalendar.get(Calendar.YEAR),mCalendar.get(Calendar.MONTH),mCalendar.get(Calendar.DAY_OF_MONTH), this);
				color = false;
7
CodeRank
This code example shows how to use the following methods:clearFocus, getCurrentHour, getCurrentMinute
			this.setButton(DialogInterface.BUTTON_POSITIVE, getContext().getText(android.R.string.ok), new DialogInterface.OnClickListener()
			{ 
				@Override 
				public void onClick(DialogInterface dialog, int which)
				{ 
					picker.clearFocus(); // focus must be cleared so the value change listener is called
					callback.onTimeSet(picker, picker.getCurrentHour(), picker.getCurrentMinute());
				} 
			}); 
		} 
		catch(Exception e)
		{ 
			// reflection probably failed 
		} 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:clearFocus, getDayOfMonth, getMonth, getYear
   * and {@link #onDialogClosed(boolean)}. Be sure to call the super when overriding. 
   */ 
  @Override 
  public void onClick(DialogInterface dialog, int which) {
    super.onClick(dialog, which);
    datePicker.clearFocus();
    onDateChanged(datePicker, datePicker.getYear(), datePicker.getMonth(),
        datePicker.getDayOfMonth());
    onDialogClosed(which == DialogInterface.BUTTON1); // OK?
  } 
 
  /** 
   * Produces the date the user has selected for the given preference, as a 
   * calendar. 
   *  
   * @param preferences 
   *          the SharedPreferences to get the date from 
   * @param field 
   *          the name of the preference to get the date from 
   * @return a Calendar that the user has selected 
6
CodeRank

Related ViewGroup clearFocus Questions & Answers:

clearFocus Method Overview
Called when this view wants to give up focus.
See Code Examples for other Android ViewGroup Methods: