本文整理匯總了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);
}