本文整理汇总了Java中android.widget.EditText.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setFocusable方法的具体用法?Java EditText.setFocusable怎么用?Java EditText.setFocusable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setFocusable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
public void showKeyboard(EditText ed) {
if (ed != null) {
ed.setFocusable(true);
ed.setFocusableInTouchMode(true);
ed.requestFocus();
InputMethodManager inputManager = (InputMethodManager) ed.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(ed, 0);
}
}
示例2: showSoftInput
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 动态显示软键盘
*/
public static void showSoftInput(Context context, EditText edit) {
edit.setFocusable(true);
edit.setFocusableInTouchMode(true);
edit.requestFocus();
InputMethodManager inputManager = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(edit, 0);
}
示例3: showSoftInput
import android.widget.EditText; //导入方法依赖的package包/类
public static void showSoftInput(EditText edit, Context context) {
edit.setFocusable(true);
edit.setFocusableInTouchMode(true);
edit.requestFocus();
InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(edit, 0);
}
示例4: showSoftInputFromWindow
import android.widget.EditText; //导入方法依赖的package包/类
/**
* EditText获取焦点并显示软键盘
*/
public static void showSoftInputFromWindow(Activity activity, EditText editText) {
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
示例5: showKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
/**显示/隐藏输入法
* @param context
* @param et
* @param toGetWindowTokenView(为null时toGetWindowTokenView = et) 包含et的父View,键盘根据toGetWindowTokenView的位置来弹出/隐藏
* @param show
*/
public static void showKeyboard(Context context, EditText et, View toGetWindowTokenView, boolean show){
if (context == null) {
Log.e(TAG, "showKeyboard context == null >> return;");
return;
}
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);//imm必须与context唯一对应
if (toGetWindowTokenView == null) {
Log.w(TAG, "showKeyboard toGetWindowTokenView == null");
toGetWindowTokenView = et;
}
if (toGetWindowTokenView == null) {
Log.e(TAG, "showKeyboard toGetWindowTokenView == null && et == null >> return;");
return;
}
if (show == false) {
imm.hideSoftInputFromWindow(toGetWindowTokenView.getWindowToken(), 0);
if (et != null) {
et.clearFocus();
}
} else {
if (et != null) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
imm.toggleSoftInputFromWindow(toGetWindowTokenView.getWindowToken()
, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
}
示例6: openSoftKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 开启软键盘
* @param et
*/
public static void openSoftKeyboard(EditText et) {
if (et != null) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
InputMethodManager inputManager = (InputMethodManager) et.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(et, 0);
}
}
示例7: showSoftInputFromWindow
import android.widget.EditText; //导入方法依赖的package包/类
/**
* EditText获取焦点并显示软键盘
*/
public void showSoftInputFromWindow(Activity activity, EditText editText) {
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
示例8: showKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
/**显示/隐藏输入法
* @param context
* @param et
* @param toGetWindowTokenView(为null时toGetWindowTokenView = et) 包含et的父View,键盘根据toGetWindowTokenView的位置来弹出/隐藏
* @param show
*/
public static void showKeyboard(Context context, EditText et, View toGetWindowTokenView, boolean show){
if (context == null) {
Log.e(TAG, "showKeyboard context == null >> return;");
return;
}
imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);//imm必须与context唯一对应
if (toGetWindowTokenView == null) {
Log.w(TAG, "showKeyboard toGetWindowTokenView == null");
toGetWindowTokenView = et;
}
if (toGetWindowTokenView == null) {
Log.e(TAG, "showKeyboard toGetWindowTokenView == null && et == null >> return;");
return;
}
if (show == false) {
imm.hideSoftInputFromWindow(toGetWindowTokenView.getWindowToken(), 0);
if (et != null) {
et.clearFocus();
}
} else {
if (et != null) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
imm.toggleSoftInputFromWindow(toGetWindowTokenView.getWindowToken()
, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
}
示例9: toggleSoftInput
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 动态软键盘
*
* @param context
* @param edit
*/
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static void toggleSoftInput(Context context, EditText edit) {
edit.setFocusable(true);
edit.setFocusableInTouchMode(true);
edit.requestFocus();
InputMethodManager inputManager = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
示例10: showSoftInput
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 弹出软键盘
*/
public static boolean showSoftInput(Context context, EditText editText) {
try {
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
InputMethodManager inputManager = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
return inputManager.showSoftInput(editText, 0);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例11: openKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
public static void openKeyboard(EditText mEditText, Context mContext) {
mEditText.setFocusable(true);
mEditText.setFocusableInTouchMode(true);
mEditText.requestFocus();
InputMethodManager inputManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(mEditText, InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
示例12: toggleSoftInput
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 切换键盘显示与否状态
*/
public static void toggleSoftInput(Context context, EditText edit) {
edit.setFocusable(true);
edit.setFocusableInTouchMode(true);
edit.requestFocus();
InputMethodManager inputManager = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
示例13: openKeyboard
import android.widget.EditText; //导入方法依赖的package包/类
private void openKeyboard(EditText view) {
view.setFocusable(true);
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
示例14: setView
import android.widget.EditText; //导入方法依赖的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);
}
}
}
}
示例15: disableEditText
import android.widget.EditText; //导入方法依赖的package包/类
public void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setOnClickListener(this);
editText.setCursorVisible(false);
editText.setBackgroundColor(Color.TRANSPARENT);
}