本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例5: setOnFocusListener
import android.view.View; //导入方法依赖的package包/类
public void setOnFocusListener(int viewId, View.OnFocusChangeListener listener) {
View view = findView(viewId);
view.setOnFocusChangeListener(listener);
}
示例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);
}