本文整理汇总了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();
}