当前位置: 首页>>代码示例>>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;未经允许,请勿转载。