當前位置: 首頁>>代碼示例>>Java>>正文


Java View.setOnFocusChangeListener方法代碼示例

本文整理匯總了Java中android.view.View.setOnFocusChangeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java View.setOnFocusChangeListener方法的具體用法?Java View.setOnFocusChangeListener怎麽用?Java View.setOnFocusChangeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.setOnFocusChangeListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addFocusChangeListener

import android.view.View; //導入方法依賴的package包/類
protected final void addFocusChangeListener(OnFocusChangeListener l){
  View view;
  if(l != null && (view = getRealView()) != null) {
    if( mFocusChangeListeners == null){
      mFocusChangeListeners = new ArrayList<>();
      view.setFocusable(true);
      view.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
          for (OnFocusChangeListener listener : mFocusChangeListeners){
            if(listener != null){
              listener.onFocusChange(hasFocus);
            }
          }
        }
      });
    }
    mFocusChangeListeners.add(l);
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:21,代碼來源:WXComponent.java

示例2: addToCustomContentPage

import android.view.View; //導入方法依賴的package包/類
public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks,
        String description) {
    if (getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID) < 0) {
        throw new RuntimeException("Expected custom content screen to exist");
    }

    // Add the custom content to the full screen custom page
    CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
    int spanX = customScreen.getCountX();
    int spanY = customScreen.getCountY();
    CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, spanX, spanY);
    lp.canReorder  = false;
    lp.isFullscreen = true;
    if (customContent instanceof Insettable) {
        ((Insettable)customContent).setInsets(mInsets);
    }

    // Verify that the child is removed from any existing parent.
    if (customContent.getParent() instanceof ViewGroup) {
        ViewGroup parent = (ViewGroup) customContent.getParent();
        parent.removeView(customContent);
    }
    customScreen.removeAllViews();
    customContent.setFocusable(true);
    customContent.setOnKeyListener(new FullscreenKeyEventListener());
    customContent.setOnFocusChangeListener(mLauncher.mFocusHandler
            .getHideIndicatorOnFocusListener());
    customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
    mCustomContentDescription = description;

    mCustomContentCallbacks = callbacks;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:33,代碼來源:Workspace.java

示例3: addEditor

import android.view.View; //導入方法依賴的package包/類
public void addEditor(View editor) {

        // editor must be MongolEditText or EditText
        if (!(editor instanceof EditText) && !(editor instanceof MongolEditText)) {
            throw new RuntimeException("MongolInputMethodManager " +
                    "only supports adding a MongolEditText or EditText " +
                    "at this time. You added: " + editor);
        }

        if (mRegisteredEditors == null) {
            mRegisteredEditors = new ArrayList<>();
        }

        // don't add the same view twice
        for (View view : mRegisteredEditors) {
            if (view == editor) return;
        }

        // give the editor's input connection to the keyboard when editor is focused
        editor.setOnFocusChangeListener(focusListener);
        // TODO if hiding the keyboard on back button then may need to add a touch listener to edit texts too

        // get extra updates from MongolEditText
        // TODO is there any way for us to get these updates from EditText?
        if (editor instanceof MongolEditText) {
            ((MongolEditText) editor).setOnMongolEditTextUpdateListener(mongolEditTextListener);
        }

        // TODO set allow system keyboard to show if hasn't been set

        // add editor
        mRegisteredEditors.add(editor);
        mCurrentEditor = editor;
    }
 
開發者ID:suragch,項目名稱:mongol-library,代碼行數:35,代碼來源:MongolInputMethodManager.java

示例4: setView

import android.view.View; //導入方法依賴的package包/類
public void setView(View view)
{
           LinearLayout l = (LinearLayout) mAlertDialogWindow.findViewById(R.id.contentView);
           l.removeAllViews();
           ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
	ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
           view.setLayoutParams(layoutParams);

           view.setOnFocusChangeListener(new View.OnFocusChangeListener() {
	    @Override public void onFocusChange(View v, boolean hasFocus)
	    {
		mAlertDialogWindow.setSoftInputMode(
                           WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
		// show imm
		InputMethodManager imm = (InputMethodManager) mContext.getSystemService(
                           Context.INPUT_METHOD_SERVICE);
		imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
				    InputMethodManager.HIDE_IMPLICIT_ONLY);
	    }
	});

           l.addView(view);

           if (view instanceof ViewGroup)
    {

               ViewGroup viewGroup = (ViewGroup) view;

               for (int i = 0; i < viewGroup.getChildCount(); i++)
	{
                   if (viewGroup.getChildAt(i) instanceof EditText)
	    {
                       EditText editText = (EditText) viewGroup.getChildAt(i);
                       editText.setFocusable(true);
                       editText.requestFocus();
                       editText.setFocusableInTouchMode(true);
                   }
               }
               for (int i = 0; i < viewGroup.getChildCount(); i++)
	{
                   if (viewGroup.getChildAt(i) instanceof AutoCompleteTextView)
	    {
                       AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) viewGroup
		    .getChildAt(i);
                       autoCompleteTextView.setFocusable(true);
                       autoCompleteTextView.requestFocus();
                       autoCompleteTextView.setFocusableInTouchMode(true);
                   }
               }
           }
       }
 
開發者ID:stytooldex,項目名稱:pius1,代碼行數:52,代碼來源:MaterialDialog.java

示例5: setOnFocusListener

import android.view.View; //導入方法依賴的package包/類
public void setOnFocusListener(int viewId, View.OnFocusChangeListener listener) {
    View view = findView(viewId);
    view.setOnFocusChangeListener(listener);
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:5,代碼來源:CustomPopupWindow.java

示例6: focus

import android.view.View; //導入方法依賴的package包/類
public static void focus(View.OnFocusChangeListener li, View...views) {
    if(views == null || views.length == 0) return;
    for(View v : views) v.setOnFocusChangeListener(li);
}
 
開發者ID:dufangyu1990,項目名稱:JKApp,代碼行數:5,代碼來源:EventHelper.java


注:本文中的android.view.View.setOnFocusChangeListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。