本文整理匯總了Java中android.view.View.OnFocusChangeListener類的典型用法代碼示例。如果您正苦於以下問題:Java OnFocusChangeListener類的具體用法?Java OnFocusChangeListener怎麽用?Java OnFocusChangeListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OnFocusChangeListener類屬於android.view.View包,在下文中一共展示了OnFocusChangeListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFocusChanged
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
@TargetApi(16)
public void onFocusChanged(boolean paramBoolean, int paramInt, Rect paramRect)
{
super.onFocusChanged(paramBoolean, paramInt, paramRect);
triggerAutocompleteSuggestionsIfPossible();
if ((!paramBoolean) && (getError() == null) && (this.mOutOfFocusFieldValidatable != null)) {
this.mOutOfFocusFieldValidatable.validate();
}
if ((paramBoolean) && (getError() != null)) {
announceError();
}
if (this.mFocusChangeListenerList != null)
{
Iterator localIterator = this.mFocusChangeListenerList.iterator();
while (localIterator.hasNext()) {
((View.OnFocusChangeListener)localIterator.next()).onFocusChange(this, paramBoolean);
}
}
}
示例2: createViewItems
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
public void createViewItems() {
this.play = (ImageButton) findViewById(R.id.playButton);
this.next = (ImageButton) findViewById(R.id.nextButton);
this.previous = (ImageButton) findViewById(R.id.previousButton);
this.random = (ImageButton) findViewById(R.id.btnShuffle);
this.loop = (ImageButton) findViewById(R.id.btnRepeat);
this.musicName = (TextView) findViewById(R.id.textView2);
this.notConnectedWarning = (TextView) findViewById(R.id.textView4);
this.warningLogo = (ImageView) findViewById(R.id.imageView2);
this.mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
this.mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
this.upload = (ImageButton) findViewById(R.id.upload_button);
this.download = (ImageButton) findViewById(R.id.download_button);
this.inputSearch = (EditText) findViewById(R.id.inputSearch);
OnFocusChangeListener ofcListener = new MyFocusChangeListener();
this.inputSearch.setOnFocusChangeListener(ofcListener);
}
示例3: attachOnTouchAndFocusListener
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attaches onTouchListener and onFocusListener to the EditText.
*
* @param editText
* The editText with which the onTouchListener and
* onFocusChangeListener are to be associated.
*/
void attachOnTouchAndFocusListener(final EditText editText) {
final String text = editText.getText().toString().trim();
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus && !(text.equals(""))) {
// check if keyboard is connected but accessibility services
// are disabled
if (!Utils.isAccessibilityEnabled(getApplicationContext())
&& getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) {
if (text.equals("")) {
// empty EditText
TTS.speak(editText.getHint().toString());
} else {
if (text.matches("-?\\d+(\\.\\d+)?")) {
TTS.readNumber(text);
} else {
TTS.speak(text);
}
}
}
}
}
});
}
示例4: attachListenerToTextView
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attach onFocusChangeListener to the TextView passed as parameter to the
* method. If a keyboard is connected to the device, a TTS feedback would be
* given to the user informing him/her about the text on the TextView that
* received focus.
*
* @param textView
* is an instance of TextView.
*/
void attachListenerToTextView(final TextView textView) {
textView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
// check if keyboard is connected but accessibility services
// are disabled
if (!Utils.isAccessibilityEnabled(getApplicationContext())
&& getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS)
giveFeedback(textView.getText().toString());
}
}
});
}
示例5: getHideIndicatorOnFocusListener
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Sets the alpha of this FocusIndicatorHelper to 0 when a view with this listener
* receives focus.
*/
public View.OnFocusChangeListener getHideIndicatorOnFocusListener() {
return new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
endCurrentAnimation();
setCurrentView(null);
setAlpha(0);
invalidateDirty();
}
}
};
}
示例6: getOnFocusChangeListener
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* 獲取焦點改變事件監聽,設置EditText文本默認全選
* @return 焦點改變事件監聽
*/
protected OnFocusChangeListener getOnFocusChangeListener() {
return new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus && v instanceof EditText) {
((EditText) v).setSelection(0, ((EditText) v).getText().length());
}
}
};
}
示例7: showButtonDone
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
private void showButtonDone(){
View view=vf.getCurrentView();
EditText etContent=(EditText) view.findViewById(R.id.aty_detail_content);
etContent.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean arg1) {
if(arg1){
biDone.setVisibility(View.VISIBLE);
}else{
biDone.setVisibility(View.GONE);
}
}
});
}
示例8: onCreate
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.entry_form);
final OnFocusChangeListener decimalNumberFormatter = new DecimalNumberFormattingOnFocusChangeListener();
valueExtreme = getTextViewAndAddResettableWatcher(R.id.value_extreme);
valueExtreme.setOnFocusChangeListener(decimalNumberFormatter);
unitExtreme = getTextViewAndAddResettableWatcher(R.id.unit_extreme);
valueMeansB = getTextViewAndAddResettableWatcher(R.id.value_means_b);
valueMeansB.setOnFocusChangeListener(decimalNumberFormatter);
unitMeansB = getTextViewAndAddResettableWatcher(R.id.unit_means_b);
valueMeansC = getTextViewAndAddResettableWatcher(R.id.value_means_c);
valueMeansC.setOnFocusChangeListener(decimalNumberFormatter);
unitMeansC = getTextViewById(R.id.unit_means_c);
valueResult = getTextViewById(R.id.value_result);
unitResult = getTextViewById(R.id.unit_result);
buttonCalculate = (Button) findViewById(R.id.entry_form_button_calculate);
buttonCalculate.setOnClickListener(createCalculateButtonOnClickListener());
buttonReset = (Button) findViewById(R.id.entry_form_button_reset);
buttonReset.setOnClickListener(createResetButtonOnClickListener());
requiredViewsForCalculation.add(valueExtreme);
requiredViewsForCalculation.add(valueMeansB);
requiredViewsForCalculation.add(valueMeansC);
}
示例9: getOnFocusChangeListener
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
public View.OnFocusChangeListener getOnFocusChangeListener()
{
if (_onFocusChangeListener == null)
{
_onFocusChangeListener = getDecorView().getOnFocusChangeListener();
}
return _onFocusChangeListener;
}
示例10: attachOnTouchAndFocusListener
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attaches onTouchListener and onFocusListener to the EditText passed as a
* parameter.
*
* @param editText
* The EditText with which the onTouchListener and
* onFocusListener are to be associated.
*/
void attachOnTouchAndFocusListener(final EditText editText) {
final String text = editText.getText().toString().trim();
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus && !(text.equals(""))) {
// check if keyboard is connected but accessibility services
// are disabled
if (!Utils.isAccessibilityEnabled(getApplicationContext())
&& getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) {
if (text.equals("")) {
// empty EditText
TTS.speak(editText.getHint().toString());
} else {
if (text.matches("-?\\d+(\\.\\d+)?")) {
TTS.readNumber(text);
} else {
TTS.speak(text);
}
}
}
}
}
});
}
示例11: attachListener
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attaches onFocusChangeListener to the button passed as a parameter. When the button receives focus, giveFeedback method is called, that reads aloud the
* string passed to it as a parameter.
*
* @param button is an instance of Button.
*/
protected void attachListener(Button button) {
final String text = button.getText().toString();
button.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
giveFeedback(text);
}
}
});
}
示例12: attachListenerToSpinner
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attachs onFocusChangeListener to the spinner passed as a parameter. When the spinner receives focus, giveFeedback method is called, that reads aloud the
* string passed to it as a parameter.
*
* @param spinner is an instance of Spinner.
*/
protected void attachListenerToSpinner(Spinner spinner) {
final String text = spinner.getContentDescription().toString();
spinner.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
giveFeedback(text);
}
}
});
}
示例13: attachListener
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attaches onFocusChange listener to the TextView passed as a parameter to
* the method, to track the change in focus of the TextView. If the TextView
* receives focus, pass the content description of the TextView to
* giveFeedback().
*
* @param textView
* This is an instance of TextView.
*/
public void attachListener(final TextView textView) {
textView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
giveFeedback(textView.getContentDescription().toString());
}
}
});
}
示例14: attachListenerToTextView
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attaches onFocusListener to the TextView passed as a parameter. The text
* specified in the TextView is sent to giveFeedback method.
*
* @param textView
* The TextView with which onFocusChange listener is to be
* associated.
**/
void attachListenerToTextView(TextView textView) {
final String text = textView.getText().toString();
textView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
giveFeedback(text);
}
}
});
}
示例15: attachListenerToTextView
import android.view.View.OnFocusChangeListener; //導入依賴的package包/類
/**
* Attaches onFocusChange listener to the TextView passed as a parameter to
* the method, to track the change in focus of the TextView. If the TextView
* receives focus, pass the content description of the TextView to
* giveFeedback().
*
* @param textView
* This is an instance of TextView.
*/
void attachListenerToTextView(TextView textView) {
textView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
giveFeedback(((TextView) view).getText().toString());
}
}
});
}