当前位置: 首页>>代码示例>>Java>>正文


Java AutoCompleteTextView.setSelection方法代码示例

本文整理汇总了Java中android.widget.AutoCompleteTextView.setSelection方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.setSelection方法的具体用法?Java AutoCompleteTextView.setSelection怎么用?Java AutoCompleteTextView.setSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.AutoCompleteTextView的用法示例。


在下文中一共展示了AutoCompleteTextView.setSelection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeUi

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void initializeUi() {
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    // Get the Layoutelements
    mBtnConnect = (Button) findViewById(R.id.btnConnect);
    mBtnConnect.setOnClickListener(oclConnect);
    mBtnConnect.requestFocus();

    mBtnMiamPlayer = (ImageButton) findViewById(R.id.btnMiamPlayerIcon);
    mBtnMiamPlayer.setOnClickListener(oclMiamPlayer);

    // Setup the animation for the MiamPlayer icon
    mAlphaDown = new AlphaAnimation(1.0f, 0.3f);
    mAlphaUp = new AlphaAnimation(0.3f, 1.0f);
    mAlphaDown.setDuration(ANIMATION_DURATION);
    mAlphaUp.setDuration(ANIMATION_DURATION);
    mAlphaDown.setFillAfter(true);
    mAlphaUp.setFillAfter(true);
    mAlphaUp.setAnimationListener(mAnimationListener);
    mAlphaDown.setAnimationListener(mAnimationListener);
    mAnimationCancel = false;

    // Ip and Autoconnect
    mEtIp = (AutoCompleteTextView) findViewById(R.id.etIp);
    mEtIp.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mEtIp.setThreshold(3);

    // Get old ip and auto-connect from shared preferences
    mEtIp.setText(mSharedPref.getString(SharedPreferencesKeys.SP_KEY_IP, ""));
    mEtIp.setSelection(mEtIp.length());

    ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
            android.R.layout.select_dialog_item, mKnownIps.toArray(new String[0]));
    mEtIp.setAdapter(adapter);

    // Get the last auth code
    mAuthCode = mSharedPref.getInt(SharedPreferencesKeys.SP_LAST_AUTH_CODE, 0);
}
 
开发者ID:MBach,项目名称:Miam-Player-remote,代码行数:39,代码来源:ConnectActivity.java

示例2: setupEditTagDialog

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
private void setupEditTagDialog() {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PopupActivity.this);
    LayoutInflater inflater = PopupActivity.this.getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.dialog_edit_tag, null);
    dialogBuilder.setView(dialogView);
    final AutoCompleteTextView editTag = (AutoCompleteTextView) dialogView.findViewById(R.id.edit_tag);
    final CheckBox checkBoxSetAsDefaultTag = (CheckBox) dialogView.findViewById(R.id.checkbox_as_default_tag);
    editTag.setImeOptions(EditorInfo.IME_ACTION_DONE);
    if (mTagEditedByUser.size() == 1) {
        String text = (String) mTagEditedByUser.toArray()[0];
        editTag.setText(text);
        editTag.setSelection(text.length());
    }
    List<UserTag> userTags = DataSupport.findAll(UserTag.class);
    String[] arr = new String[userTags.size()];
    for (int i = 0; i < userTags.size(); i++) {
        arr[i] = userTags.get(i).getTag();
    }
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(PopupActivity.this,
            R.layout.support_simple_spinner_dropdown_item, arr);
    editTag.setAdapter(arrayAdapter);
    editTag.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (editTag.getText().toString().isEmpty()) {
                editTag.showDropDown();
            }
            return false;
        }
    });
    boolean setDefaultQ = settings.getSetAsDefaultTag();
    checkBoxSetAsDefaultTag.setChecked(setDefaultQ);
    dialogBuilder.setTitle(R.string.dialog_tag);
    //dialogBuilder.setMessage("输入笔记");
    dialogBuilder.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String tag = editTag.getText().toString().trim();
            if (tag.isEmpty()) {
                if (checkBoxSetAsDefaultTag.isChecked()) {
                    mTagEditedByUser.clear();
                    Toast.makeText(PopupActivity.this, R.string.tag_cant_be_blank, Toast.LENGTH_LONG).show();
                } else {
                    settings.setSetAsDefaultTag(false);
                    mTagEditedByUser.clear();
                }
                return;
            } else {
                mTagEditedByUser.clear();
                mTagEditedByUser.add(tag);
                settings.setSetAsDefaultTag(checkBoxSetAsDefaultTag.isChecked());
                settings.setDefaultTag(tag);
                UserTag userTag = new UserTag(tag);
                userTag.save();
            }

        }
    });
    AlertDialog b = dialogBuilder.create();
    b.show();
}
 
开发者ID:mmjang,项目名称:ankihelper,代码行数:61,代码来源:PopupActivity.java


注:本文中的android.widget.AutoCompleteTextView.setSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。