本文整理匯總了Java中android.widget.EditText.clearFocus方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.clearFocus方法的具體用法?Java EditText.clearFocus怎麽用?Java EditText.clearFocus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.EditText
的用法示例。
在下文中一共展示了EditText.clearFocus方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setEditable
import android.widget.EditText; //導入方法依賴的package包/類
/**
* Input frame character length limit
*
* @param mEdit EditText
* @param maxLength maxLength
*/
public void setEditable(EditText mEdit, int maxLength) {
if (mEdit.getText().length() < maxLength) {
mEdit.setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxLength) {
}});
mEdit.setCursorVisible(true);
mEdit.setFocusableInTouchMode(true);
mEdit.requestFocus();
} else {
mEdit.setFilters(new InputFilter[]{new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
}
}});
mEdit.setCursorVisible(false);
mEdit.setFocusableInTouchMode(false);
mEdit.clearFocus();
}
}
示例2: afterTextChanged
import android.widget.EditText; //導入方法依賴的package包/類
@Override
public void afterTextChanged(Editable s) {
if (s != null && s.length() == 1) {
if (index < 7) {// 焦點後移
Log.d("gaolei", "index------------------" + index);
if (index < 6) {
EditText editText = getEditTextFromIndex(index);
editText.clearFocus();
getEditTextFromIndex(index + 1).requestFocusFromTouch();
}
currentEditIndex = index;
} else {
// TODO 判斷
// handler.sendEmptyMessage(1);
}
} else {
// 清除 對應 標識位
}
}
示例3: onCreate
import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSharedPreference = getSharedPreferences("htmlnative-demo", MODE_PRIVATE);
String url = mSharedPreference.getString("url", "");
mContainer = (RelativeLayout) findViewById(R.id.relative_view);
mSearch = (EditText) findViewById(R.id.search_editbox);
mSearch.setText(url);
mGo = (ImageButton) findViewById(R.id.search_go_btn);
mGo.setOnClickListener(this);
mLoader = new RemoteViewLoader(this);
mSearch.clearFocus();
}
示例4: initView
import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void initView()
{
if (!TextUtils.isEmpty(mTitle))
{
setActionBarTitle(mTitle);
}
send_comment = (TextView) findViewById(R.id.send_comment);
et_content = (EditText) findViewById(R.id.et_content);
send_comment.setOnClickListener(this);
et_content.setSelected(false);
et_content.clearFocus();
//ViewUtils.hideSoftInput(this);
//et_content.clearFocus();
}
示例5: getClearListener
import android.widget.EditText; //導入方法依賴的package包/類
@NonNull
private View.OnTouchListener getClearListener(final EditText editText) {
return new View.OnTouchListener() {
final int DRAWABLE_LEFT = 0;
final int DRAWABLE_TOP = 1;
final int DRAWABLE_RIGHT = 2;
final int DRAWABLE_BOTTOM = 3;
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
int leftEdgeOfRightDrawable = editText.getRight()
- editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width();
// when EditBox has padding, adjust leftEdge like
// leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right);
if (event.getRawX() >= leftEdgeOfRightDrawable) {
// clicked on clear icon
editText.setText("");
editText.clearFocus();
return true;
}
}
return false;
}
};
}
示例6: 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);
}
}
}
示例7: 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);
}
}
}
示例8: onInactive
import android.widget.EditText; //導入方法依賴的package包/類
public static void onInactive(Context context, EditText et) {
if (et == null)
return;
et.clearFocus();
hideSoftInput(context,et);
}
示例9: setEditTextEditable
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 設置EditText是否可編輯
*
* @param editText 要設置的EditText
* @param value 可編輯:true 不可編輯:false
* @author com.tiantian
*/
public static void setEditTextEditable(EditText editText, boolean value)
{
if (value)
{
editText.setFocusableInTouchMode(true);
editText.requestFocus();
} else
{
editText.setFocusableInTouchMode(false);
editText.clearFocus();
}
}
示例10: hideSoftInput
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 動態隱藏軟鍵盤
*/
public static void hideSoftInput(Context context, EditText edit) {
edit.clearFocus();
InputMethodManager inputmanger = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0);
}
示例11: processEvent
import android.widget.EditText; //導入方法依賴的package包/類
private void processEvent(String type, EditText editText, PhysioTimestamp timestamp, TextView textView) {
// This is a boilerplate code
String value = editText.getText().toString();
if (value.equals("")) {
Toast.makeText(this, "Can't send an empty value", Toast.LENGTH_LONG).show();
return;
}
LogicTupleEvent lte = new LogicTupleEvent(type, value);
lte.setTimestamp(timestamp.timestamp.toDate().getTime());
sendEvent(lte);
editText.setText("");
editText.clearFocus();
textView.setText("-");
}
示例12: onInactive
import android.widget.EditText; //導入方法依賴的package包/類
public static void onInactive(Context context, EditText et) {
if (et == null)
return;
et.clearFocus();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(et.getWindowToken(), 0);
}
示例13: hideSoftInput
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 動態隱藏軟鍵盤
*
* @param edit 輸入框
*/
public static void hideSoftInput(EditText edit) {
edit.clearFocus();
InputMethodManager inputManger = (InputMethodManager)
sContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputManger != null) {
inputManger.hideSoftInputFromWindow(edit.getWindowToken(), 0);
}
}
示例14: hideKeyboard
import android.widget.EditText; //導入方法依賴的package包/類
public static void hideKeyboard(Activity activity, EditText editText, int i, String text, String hint) {
editText.clearFocus();
editText.setText("Search Here...");
editText.setHint(hint);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
sharedPref.edit().putInt("keyboard", i).apply();
activity.invalidateOptionsMenu();
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
示例15: hideInputMethod
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 隱藏軟鍵盤
*
* @param v
*/
public void hideInputMethod(final EditText v) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(),0);
v.clearFocus();
}