setFocusable ( )源码实例Demo

android.widget.EditText#setFocusable ( )源码实例Demo

下面列出了android.widget.EditText#setFocusable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: biermacht   文件: AlertBuilder.java
public AlertDialog.Builder editTextDisabled(final TextView text, final TextView title, String message) {
  LayoutInflater factory = LayoutInflater.from(context);
  final LinearLayout alertView = (LinearLayout) factory.inflate(R.layout.alert_view_edit_text_float_2_4, null);
  final EditText editText = (EditText) alertView.findViewById(R.id.edit_text);
  final TextView messageView = new TextView(this.context);
  messageView.setText(message);
  messageView.setGravity(Gravity.CENTER);
  alertView.addView(messageView);

  // Set text
  editText.setText(text.getText().toString());

  // Set disabled.
  editText.setEnabled(false);
  editText.setClickable(false);
  editText.setFocusable(false);
  editText.setFocusableInTouchMode(false);

  return new AlertDialog.Builder(context)
          .setTitle(title.getText().toString())
          .setView(alertView)
          .setPositiveButton(R.string.ok, null);
}
 
源代码2 项目: belvedere   文件: KeyboardHelper.java
private KeyboardHelper(@NonNull Activity activity) {
    super(activity);
    this.statusBarHeight = getStatusBarHeight();
    int sizeForDummyView = activity.getResources()
            .getDimensionPixelSize(zendesk.belvedere.ui.R.dimen.belvedere_dummy_edit_text_size);
    setLayoutParams(new ViewGroup.LayoutParams(sizeForDummyView, sizeForDummyView));

    inputTrap = new EditText(activity);
    inputTrap.setFocusable(true);
    inputTrap.setFocusableInTouchMode(true);
    inputTrap.setVisibility(View.VISIBLE);
    inputTrap.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    inputTrap.setInputType(EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);

    addView(inputTrap);

    final View rootView = activity.getWindow().getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
    rootView.getViewTreeObserver().addOnGlobalLayoutListener(new KeyboardTreeObserver(activity));
}
 
源代码3 项目: timecat   文件: KeyboardUtil.java
/**
 * 针对于EditText 获得焦点,显示软键盘
 *
 * @param edit EditText
 */
public void showKeyboard(EditText edit) {
    edit.setFocusable(true);
    edit.setFocusableInTouchMode(true);
    edit.requestFocus();
    imm.showSoftInput(edit, 0);
}
 
源代码4 项目: SearchPreference   文件: SearchPreference.java
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    EditText searchText = (EditText) holder.findViewById(R.id.search);
    searchText.setFocusable(false);
    searchText.setInputType(InputType.TYPE_NULL);
    searchText.setOnClickListener(this);

    if (hint != null) {
        searchText.setHint(hint);
    }

    holder.findViewById(R.id.search_card).setOnClickListener(this);
    holder.itemView.setOnClickListener(this);
    holder.itemView.setBackgroundColor(0x0);
}
 
源代码5 项目: BotLibre   文件: ScriptEditorActivity.java
public void resetView(){
	this.source = (ScriptSourceConfig)MainActivity.script;
	
	TextView title = (TextView)findViewById(R.id.title);
	title.setText(Utils.stripTags(this.instance.name));
	
	String script = source.source;
	
	EditText editScript = (EditText)findViewById(R.id.scriptSource);
	Button saveButton = (Button)findViewById(R.id.saveScriptButton);
	
	if (script != null && !script.equals("")) {
		editScript.setText(script);
	}
	else {
		editScript.setText("");
	}
	
	boolean isAdmin = (MainActivity.user != null) && instance.isAdmin;
	if (!isAdmin || instance.isExternal) {
		editScript.setFocusable(false);
		saveButton.setEnabled(false);
		saveButton.setVisibility(View.GONE);
	} else {
		editScript.setFocusableInTouchMode(true);
		saveButton.setEnabled(true);
	}
}
 
源代码6 项目: BotLibre   文件: ScriptEditorActivity.java
public void resetView(){
	this.source = (ScriptSourceConfig)MainActivity.script;
	
	TextView title = (TextView)findViewById(R.id.title);
	title.setText(Utils.stripTags(this.instance.name));
	
	String script = source.source;
	
	EditText editScript = (EditText)findViewById(R.id.scriptSource);
	Button saveButton = (Button)findViewById(R.id.saveScriptButton);
	
	if (script != null && !script.equals("")) {
		editScript.setText(script);
	}
	else {
		editScript.setText("");
	}
	
	boolean isAdmin = (MainActivity.user != null) && instance.isAdmin;
	if (!isAdmin || instance.isExternal) {
		editScript.setFocusable(false);
		saveButton.setEnabled(false);
		saveButton.setVisibility(View.GONE);
	} else {
		editScript.setFocusableInTouchMode(true);
		saveButton.setEnabled(true);
	}
}
 
源代码7 项目: RxTools-master   文件: RxKeyboardTool.java
/**
 * 切换键盘显示与否状态
 *
 * @param context 上下文
 * @param edit    输入框
 */
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);
}
 
源代码8 项目: mobile-manager-tool   文件: UIHelp.java
public static void showSoftInputFromWindow(EditText editText)
{
    editText.setFocusable(true);
    editText.setFocusableInTouchMode(true);
    editText.requestFocus();
    InputMethodManager inputManager = (InputMethodManager) editText.getContext().getSystemService(
            Context.INPUT_METHOD_SERVICE);
    inputManager.showSoftInput(editText, 0);
}
 
源代码9 项目: Ticket-Analysis   文件: KeyboardUtils.java
/**
 * 动态显示软键盘
 */
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);
}
 
源代码10 项目: PocketMaps   文件: Permission.java
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (sPermission == null) { finish(); return; }
  setContentView(R.layout.activity_text);
  Button okButton = (Button) findViewById(R.id.okTextButton);
  EditText listText = (EditText) findViewById(R.id.areaText);
  listText.setFocusable(false);
  listText.setText(getPermissionText());
  okButton.setOnClickListener(this);
}
 
源代码11 项目: LLApp   文件: AbsBaseActivity.java
/**
 * show inputMethod
 */
public void showSoftKeyboard(final EditText editText) {
    editText.setFocusable(true);
    editText.setFocusableInTouchMode(true);
    editText.requestFocus();
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
                       public void run() {
                           InputMethodManager inputManager =
                                   (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                           inputManager.showSoftInput(editText, 0);
                       }
                   },
            400);
}
 
源代码12 项目: o2oa   文件: EmoticonsKeyboardUtils.java
/**
 * 开启软键盘
 * @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);
    }
}
 
源代码13 项目: WiFiAfterConnect   文件: EditCredentialsActivity.java
private void addField (HtmlInput field) {
Log.d(Constants.TAG, "adding ["+field.getName() + "], type = [" + field.getType()+"]");

  	TextView labelView =  new TextView(this);
  	labelView.setText(field.getName());
  	int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, (float) 8, getResources().getDisplayMetrics());
  	labelView.setTextSize (textSize);
  	
  	EditText editView = new EditText(this);
  	editView.setInputType(field.getAndroidInputType());
  	editView.setText (field.getValue());
  	editView.setTag(field.getName());
  	editView.setFocusable (true);
  	
  	edits.add(editView);
  	
  	editView.setOnEditorActionListener(new EditText.OnEditorActionListener() {
	@Override
	public boolean onEditorAction(TextView v, int actionId,	KeyEvent event) {
  			if (actionId == EditorInfo.IME_ACTION_DONE) {
  				onSaveClick(v);
  			}
  			return false;
	}

  	});    	
  	
  	TableRow row = new TableRow (this);
	fieldsTable.addView (row, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,TableLayout.LayoutParams.WRAP_CONTENT));

  	TableRow.LayoutParams labelLayout = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
  	int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 5, getResources().getDisplayMetrics());
  	labelLayout.setMargins(margin, margin, margin, margin);
  	row.addView(labelView, labelLayout);
  	TableRow.LayoutParams editLayout = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.WRAP_CONTENT);
  	row.addView(editView, editLayout);
  }
 
源代码14 项目: Conversations   文件: PinEntryWrapper.java
public void setEnabled(final boolean enabled) {
    for (EditText digit : digits) {
        digit.setEnabled(enabled);
        digit.setCursorVisible(enabled);
        digit.setFocusable(enabled);
        digit.setFocusableInTouchMode(enabled);
    }
    if (enabled) {
        final EditText last = digits.get(digits.size() - 1);
        if (last.getEditableText().length() > 0) {
            last.requestFocus();
        }
    }
}
 
源代码15 项目: UGank   文件: KeyboardUtils.java
/**
 * 动态显示软键盘
 *
 * @param edit 输入框
 */
public static void showSoftInput(Context context, EditText edit) {
    edit.setFocusable(true);
    edit.setFocusableInTouchMode(true);
    edit.requestFocus();
    InputMethodManager imm = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(edit, 0);
}
 
源代码16 项目: YCAudioPlayer   文件: AppToolUtils.java
/**
 * 设置焦点
 * @param et                    et
 */
public static void SetEditTextFocus(EditText et){
    et.setFocusable(true);
    et.setFocusableInTouchMode(true);
    et.requestFocus();
}
 
源代码17 项目: file-downloader   文件: MainActivity.java
private void showNewDownloadDialog() {

        final EditText etUrl = new EditText(this);
        // apk file, the url with special character
        etUrl.setText("  http://182.254.149.157/ftp/image/shop/product/Kids Addition & Subtraction 1.0.apk ");

        // etUrl.setText("http://yjh.t4s.cn/Uploads/Download/2016-01-13/56962102baf32.apk");

        // etUrl.setText("http://yjh.t4s.cn/Home/new/downloadFile/id/31");

        //        etUrl.setText("http://openapi.shafa.com/v1/redirect?a=download&app_key=NVdVOkqg49GR090O&l=com
        // .gitvdemo" +
        //                ".video&to=http%3A%2F%2Fapps.sfcdn.org%2Fapk%2Fcom.gitvdemo.video
        // .7e9b0a7643b0c5bfbc5ddd05f41f783c" +
        //                ".apk&sign=c2046ccd3928abf6cee0d6f5d06ba6e5");
        //        etUrl.setText("http://m.25az
        // .com/upload/ad/uc/m/%e6%a2%a6%e5%b9%bb%e9%a9%af%e9%be%99%e8%ae%b0/uc-3_5011991_163309b77bf2.apk");

        // etUrl.setText(" http://cdn.saofu.cn/appss/74b6a96f-e056-4fbf-8b36-579a7d4f2ad8.apk");// only for testing
        // error url

        // test Baidu SkyDrive 
        //        etUrl.setText("https://pcscdns.baidu" +
        //                ".com/file/9d2525e48beae74df9839bfd53ea0659?bkt=p3" +
        //                "-14009d2525e48beae74df9839bfd53ea0659120c4aed0000003439bb&xcode" +
        //                "=b55811de01cef039a63384887845d600365bdbc88d13f3a00b2977702d3e6764&fid=4080794744-250528" +
        //                "-405950091149355&time=1458524792&sign=FDTAXGERLBH-DCb740ccc5511e5e8fedcff06b081203
        // -6HU2GtKiI5uAmRbD" +
        //                "%2BxWDQ0Ue54I%3D&to=se&fm=Yan,B,T,t&sta_dx=3&sta_cs=8&sta_ft=apk&sta_ct=1&fm2=Yangquan,B,
        // T," +
        //                "t&newver=1&newfm=1&secfm=1&flow_ver=3&pkey
        // =14009d2525e48beae74df9839bfd53ea0659120c4aed0000003439bb" +
        //                "&sl=69402703&expires=8h&rt=sh&r=888204069&mlogid=1864872734416013050&vuk=3339143945&vbdid
        // =1177775768" +
        //                "&fin=%E5%BE%AE%E4%BF%A1QQ%E5%8F%8C%E5%BC%80%E5%8A%A9%E6%89%8B" +
        //                ".apk&fn=%E5%BE%AE%E4%BF%A1QQ%E5%8F%8C%E5%BC%80%E5%8A%A9%E6%89%8B" +
        //                ".apk&slt=pm&uta=0&rtype=1&iv=0&isw=0&dp-logid=1864872734416013050&dp-callid=0.1.1");

        etUrl.setFocusable(true);

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.main__please_input_download_file)).setView(etUrl).setNegativeButton
                (getString(R.string.main__dialog_btn_cancel), null);
        builder.setPositiveButton(getString(R.string.main__dialog_btn_confirm), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // file url
                String url = etUrl.getText().toString().trim();

                boolean isDownloadConfigurationTest = false;// TEST

                if (!isDownloadConfigurationTest) {
                    FileDownloader.start(url);
                } else {
                    // TEST DownloadConfiguration
                    DownloadConfiguration.Builder builder1 = new DownloadConfiguration.Builder();
                    builder1.addHeader("Accept", "*/*");
                    FileDownloader.start(url, builder1.build());
                }
            }
        });
        builder.show();
    }
 
源代码18 项目: biermacht   文件: AlertBuilder.java
public AlertDialog.Builder editTextFloatCheckBoxAlert(final TextView text, final TextView title, boolean checked, final BooleanCallback cb) {
  LayoutInflater factory = LayoutInflater.from(context);
  final LinearLayout alertView = (LinearLayout) factory.inflate(R.layout.alert_view_edit_text_float_with_check_box, null);
  final EditText editText = (EditText) alertView.findViewById(R.id.edit_text);
  final CheckBox checkBox = (CheckBox) alertView.findViewById(R.id.check_box);

  // Set text
  editText.setText(text.getText().toString());

  checkBox.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      cb.call(checkBox.isChecked());
      if (checkBox.isChecked()) {
        editText.setEnabled(false);
        editText.setClickable(false);
        editText.setFocusable(false);
        editText.setFocusableInTouchMode(false);
        editText.setText(text.getText().toString());
      }
      else {
        editText.setEnabled(true);
        editText.setClickable(true);
        editText.setFocusable(true);
        editText.setFocusableInTouchMode(true);
      }
    }
  });

  // Set the box to be checked or not.
  checkBox.setChecked(checked);

  // If checked initially, grey out edit text
  if (checked) {
    editText.setEnabled(false);
    editText.setClickable(false);
    editText.setFocusable(false);
    editText.setFocusableInTouchMode(false);
  }

  return new AlertDialog.Builder(context)
          .setTitle(title.getText().toString())
          .setView(alertView)
          .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
              text.setText(editText.getText().toString());
              callback.call();
              cb.call(checkBox.isChecked());
            }

          })

          .setNegativeButton(R.string.cancel, null);
}
 
源代码19 项目: commcare-android   文件: StringWidget.java
public StringWidget(Context context, FormEntryPrompt prompt, boolean secret, boolean inCompactGroup) {
    super(context, prompt, inCompactGroup);
    mAnswer = (EditText)LayoutInflater.from(getContext()).inflate(getAnswerLayout(), this, false);
    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize);
    mAnswer.setOnClickListener(this);

    mAnswer.addTextChangedListener(this);

    //Let's see if we can figure out a constraint for this string
    try {
        addAnswerFilter(new InputFilter.LengthFilter(guessMaxStringLength(prompt)));
    } catch (UnpivotableExpressionException e) {
        //expected if there isn't a constraint that does this
    }

    this.secret = secret;

    if (!secret) {
        // capitalize the first letter of the sentence
        mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));
    }
    setTextInputType(mAnswer);

    if (!secret) {
        mAnswer.setSingleLine(false);
    }

    if (prompt != null) {
        mReadOnly = prompt.isReadOnly();
        IAnswerData value = prompt.getAnswerValue();
        if (value != null) {
            mAnswer.setText(value.getDisplayText());
        }

        if (mReadOnly) {
            if (value == null) {
                mAnswer.setText("---");
            }
            mAnswer.setBackgroundDrawable(null);
            mAnswer.setFocusable(false);
            mAnswer.setClickable(false);
        }
    }

    if (isInCompactMode()) {
        addToCompactLayout(mAnswer);
    } else {
        addView(mAnswer);
    }
}
 
源代码20 项目: RichEditor   文件: RichAdapter.java
/**
 * 文本编辑器
 */
private void bindEditComponent(RecyclerView.ViewHolder holder, final int pos, final
RichModel item) {
    if (holder instanceof EditHolder) {
        final EditText mEdit = ((EditHolder) holder).mEt;
        mEtHolder.add(mEdit);
        if (index == pos) {
            mCurEdit = ((EditHolder) holder).mEt;
            mEdit.setFocusable(true);
            mEdit.setFocusableInTouchMode(true);
            mEdit.requestFocus();
        } else {
            mEdit.setFocusable(false);
        }
        ((EditHolder) holder).textWatcher.updatePosition(pos);
        ((EditHolder) holder).filter.updatePosition(pos);
        mEdit.setTextSize(Const.DEFAULT_TEXT_SIZE);
        if (item.isParagraphStyle) {
            SpannableStringBuilder spannableString = new SpannableStringBuilder(item.source);
            for (Object obj : item.paragraphSpan.mSpans) {
                if (obj instanceof AbsoluteSizeSpan) {
                    AbsoluteSizeSpan sizeSpan = (AbsoluteSizeSpan) obj;
                    mEdit.setTextSize(sizeSpan.getSize());
                    continue;
                }
                spannableString.setSpan(obj, 0, item.source.length(), Spanned
                        .SPAN_EXCLUSIVE_EXCLUSIVE);
            }
            mEdit.setText(spannableString);
            paragraphHelper.handleTextStyle(mEdit, item.paragraphSpan.paragraphType);
        } else {
            mSpanString.clear();
            mSpanString.clearSpans();
            mSpanString.append(item.source);
            if (isEnter) {
                for (SpanModel span : item.getSpanList()) {
                    mSpanString.setMultiSpans(span.mSpans, span.start, span.end, Spanned
                            .SPAN_EXCLUSIVE_EXCLUSIVE);
                }
            }
            mEdit.setText(mSpanString);
            paragraphHelper.handleTextStyle(mEdit, -1);
        }
        mEdit.setSelection(item.curIndex);
        //mEdit.setSelection(item.source.length());
        mEdit.setHint(item.hint);
        mEdit.setTag(pos);
        //只存在一个EditText的时候,点击区域太小,所以只有一个的时候,将MinHeight设为500
        if (index == pos && index < 2 && index == mData.size() - 1) {
            mEdit.setMinHeight(DensityUtil.dp2px(mContext, 500));
        } else {
            mEdit.setMinHeight(DensityUtil.dp2px(mContext, 0));
        }
    }

}