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


Java EditText.setOnKeyListener方法代码示例

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


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

示例1: initWidgets

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
    super.initWidgets();
    mReminderLayout = (LinearLayout) findViewById(R.id.kf5_serch_reminder_layout);
    mReminderLayout.setOnClickListener(this);
    mSearchLayout = (RelativeLayout) findViewById(R.id.kf5_search_layout_content);
    mEditText = (EditText) findViewById(R.id.kf5_search_content_edittext);
    mEditText.setOnKeyListener(this);
    mImageDelete = (ImageView) findViewById(R.id.kf5_img_delete_content);
    mImageDelete.setOnClickListener(this);
    mListView = (RefreshListView) findViewById(R.id.kf5_help_center_listview);
    mListView.setOnScrollState(this);
    mListView.setOnScrollChange(this);
    mListView.addFooterView();
    mListView.setOnRefreshListener(this);
    mListView.setOnItemClickListener(this);
    mHelpCenterAdapter = new HelpCenterAdapter(mActivity, listItem);
    mListView.setAdapter(mHelpCenterAdapter);
    mTitleView = (TextView) findViewById(R.id.kf5_title);
    mTitleView.setText(R.string.kf5_article_list);
    mRightView = (TextView) findViewById(R.id.kf5_right_text_view);
    mRightView.setOnClickListener(this);
    mTimer = new Timer();
    mBackImage = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImage.setOnClickListener(this);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:27,代码来源:HelpCenterTypeChildActivity.java

示例2: initWidgets

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
    super.initWidgets();
    mReminderLayout = (LinearLayout) findViewById(R.id.kf5_serch_reminder_layout);
    mReminderLayout.setOnClickListener(this);
    mSearchLayout = (RelativeLayout) findViewById(R.id.kf5_search_layout_content);
    mEditText = (EditText) findViewById(R.id.kf5_search_content_edittext);
    mEditText.setOnKeyListener(this);
    mImageDelete = (ImageView) findViewById(R.id.kf5_img_delete_content);
    mImageDelete.setOnClickListener(this);
    mListView = (RefreshListView) findViewById(R.id.kf5_help_center_listview);
    mListView.setOnScrollState(this);
    mListView.setOnScrollChange(this);
    mListView.addFooterView();
    mListView.setOnRefreshListener(this);
    mListView.setOnItemClickListener(this);
    mHelpCenterAdapter = new HelpCenterAdapter(mActivity, listItem);
    mListView.setAdapter(mHelpCenterAdapter);
    mTitleView = (TextView) findViewById(R.id.kf5_title);
    mTitleView.setText(R.string.kf5_article_category);
    mRightView = (TextView) findViewById(R.id.kf5_right_text_view);
    mRightView.setOnClickListener(this);
    mTimer = new Timer();
    mBackImage = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImage.setOnClickListener(this);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:27,代码来源:HelpCenterActivity.java

示例3: initWidgets

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
    super.initWidgets();
    mReminderLayout = (LinearLayout) findViewById(R.id.kf5_serch_reminder_layout);
    mReminderLayout.setOnClickListener(this);
    mSearchLayout = (RelativeLayout) findViewById(R.id.kf5_search_layout_content);
    mEditText = (EditText) findViewById(R.id.kf5_search_content_edittext);
    mEditText.setOnKeyListener(this);
    mImageDelete = (ImageView) findViewById(R.id.kf5_img_delete_content);
    mImageDelete.setOnClickListener(this);
    mListView = (RefreshListView) findViewById(R.id.kf5_help_center_listview);
    mListView.setOnScrollState(this);
    mListView.setOnScrollChange(this);
    mListView.addFooterView();
    mListView.setOnRefreshListener(this);
    mListView.setOnItemClickListener(this);
    mHelpCenterAdapter = new HelpCenterAdapter(mActivity, listItem);
    mListView.setAdapter(mHelpCenterAdapter);
    mTitleView = (TextView) findViewById(R.id.kf5_title);
    mTitleView.setText(R.string.kf5_article_section);
    mRightView = (TextView) findViewById(R.id.kf5_right_text_view);
    mRightView.setOnClickListener(this);
    mTimer = new Timer();
    mBackImage = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImage.setOnClickListener(this);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:27,代码来源:HelpCenterTypeActivity.java

示例4: generateOneEditText

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * Takes care of styling the editText passed in the param.
 * tag is the index of the editText.
 *
 * @param styleEditText
 * @param tag
 */
private void generateOneEditText(EditText styleEditText, String tag) {
    params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
    filters[0] = new InputFilter.LengthFilter(1);
    styleEditText.setFilters(filters);
    styleEditText.setLayoutParams(params);
    styleEditText.setGravity(Gravity.CENTER);
    styleEditText.setCursorVisible(mCursorVisible);

    if (!mCursorVisible) {
        styleEditText.setClickable(false);
        styleEditText.setHint(mHint);

        styleEditText.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
                mDelPressed = false;
                return false;
            }
        });
    }
    styleEditText.setBackgroundResource(mPinBackground);
    styleEditText.setPadding(0, 0, 0, 0);
    styleEditText.setTag(tag);
    styleEditText.setInputType(getKeyboardInputType());
    styleEditText.addTextChangedListener(this);
    styleEditText.setOnFocusChangeListener(this);
    styleEditText.setOnKeyListener(this);
}
 
开发者ID:GoodieBag,项目名称:Pinview,代码行数:37,代码来源:Pinview.java

示例5: setEnterKeyListener

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * 监听输入法的回车按键
 */
public static void setEnterKeyListener(EditText editText, final View.OnClickListener listener) {
	editText.setOnKeyListener(new View.OnKeyListener() {
		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			// 这两个条件必须同时成立,如果仅仅用了enter判断,就会执行两次
			if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
				listener.onClick(v);
				return true;
			}
			return false;
		}
	});
}
 
开发者ID:TIIEHenry,项目名称:TIIEHenry-Android-SDK,代码行数:17,代码来源:KeyBoardManager.java

示例6: setListHeader

import android.widget.EditText; //导入方法依赖的package包/类
private void setListHeader(ListView listView) {
    ViewGroup header = (ViewGroup) getLayoutInflater().inflate(
            R.layout.view_task_create, listView, false);

    final ImageView imageView = (ImageView) header.findViewById(R.id.image);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            displayAttachImageDialog(null);
        }
    });

    final EditText text = (EditText) header.findViewById(R.id.text);
    text.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) &&
                    (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                String inputText = text.getText().toString();
                if (inputText.length() > 0)
                    createTask(inputText, mImageToBeAttached, mListId);

                text.setText("");
                deleteCurrentPhoto();

                return true;
            }
            return false;
        }
    });

    listView.addHeaderView(header);
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:34,代码来源:TaskActivity.java

示例7: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:41,代码来源:SearchBookContentsActivity.java

示例8: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // The floating action button.
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Please enter your username and password.", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    // They should log in.
    logInBool = true;

    // Define our views.
    registerText = (TextView)findViewById(R.id.registerText);
    logInButton = (Button)findViewById(R.id.loginButton);
    passText = (EditText) findViewById(R.id.passwordEditText);
    nameText = (EditText)findViewById(R.id.nameEditText);
    linLogLay = (LinearLayout)findViewById(R.id.linLogLay);
    camLogo = (ImageView)findViewById(R.id.camLogo);

    // Define our listeners.
    camLogo.setOnClickListener(this);
    linLogLay.setOnClickListener(this);
    passText.setOnKeyListener(this);
    

    // Set the default values
    logInButton.setText("Log in!");
    registerText.setText("Register");

}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:40,代码来源:LoginActivity.java

示例9: createEditText

import android.widget.EditText; //导入方法依赖的package包/类
private EditText createEditText(String hint, int Padding) {
    EditText editText = (EditText) inflater.inflate(R.layout.item_edittext, null);
    editText.setTag(viewTag++);
    editText.setOnFocusChangeListener(focusChangeListener);
    editText.setOnKeyListener(keyListener);
    editText.setPadding(dip2px(EDIT_PADDING_TOP), Padding, dip2px(EDIT_PADDING_TOP), 0);
    editText.setHint(hint);
    return editText;
}
 
开发者ID:appteam-nith,项目名称:Hillffair17,代码行数:10,代码来源:EditorView.java

示例10: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Intent intent = getIntent();
    if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && !initialQuery.isEmpty()) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
            resultListView, false);
    resultListView.addHeaderView(headerView);
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:37,代码来源:SearchBookContentsActivity.java

示例11: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
@Override
@TargetApi(23)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_password);

    textView = (TextView) findViewById(R.id.errorText);
    passwordInput = (EditText) findViewById(R.id.password_input);

    passwordInput.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_ENTER
                    && event.getAction() == KeyEvent.ACTION_UP) {

                String password = ((EditText) v).getText().toString();

                SharedPreferences preferences = getSharedPreferences(Utilities.PASSWORD_SHARED_PREF, MODE_PRIVATE);
                String passEncrypted = preferences.getString(Utilities.encrypt("password"), Utilities.encrypt("NULLPASS"));
                String pass = Utilities.decrypt(passEncrypted);
                if(!password.equals(pass)){
                    textView.setText(getString(R.string.password_failed));
                }else{
                    textView.setText(getString(R.string.password_succeded));
                    textView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDarkFinger));
                    Intent returnIntent = new Intent();
                    returnIntent.putExtra("resultPassword", true);
                    setResult(Activity.RESULT_OK, returnIntent);
                    finish();
                }

            }

            return false;
        }
    });

}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:41,代码来源:PasswordActivitySettings.java

示例12: createEditText

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * 生成文本输入框
 */
public EditText createEditText(String hint, int paddingTop) {
    EditText editText = (EditText) inflater.inflate(R.layout.hyper_edit_text, null);
    editText.setOnKeyListener(keyListener);
    editText.setTag(viewTagIndex++);
    editText.setPadding(0, paddingTop, 0, paddingTop);
    editText.setHint(hint);
    editText.setOnFocusChangeListener(focusListener);
    return editText;
}
 
开发者ID:yangchong211,项目名称:YCCustomText,代码行数:13,代码来源:HyperTextEditor.java

示例13: onCreate

import android.widget.EditText; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_code_unlock);
        Log.d("gaolei", "CodeUnlockActivity------------onCreate------------------");


//        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.dp2px(this, 50));
//        layoutParams.setMargins(0, statusBarHeight, 0, 0);//4个参数按顺序分别是左上右下
//        title_layout.setLayoutParams(layoutParams);
        setStatusBar();

        editText1 = (EditText) findViewById(R.id.editText1);
        editText2 = (EditText) findViewById(R.id.editText2);
        editText3 = (EditText) findViewById(R.id.editText3);
        editText4 = (EditText) findViewById(R.id.editText4);
        editText5 = (EditText) findViewById(R.id.editText5);
        editText6 = (EditText) findViewById(R.id.editText6);
        editText1.setTag(1);
        editText2.setTag(2);
        editText3.setTag(3);
        editText4.setTag(4);
        editText5.setTag(5);
        editText6.setTag(6);
        // 添加 内容change listener :输入焦点后移 + 密码验证
        editText1.addTextChangedListener(new MyTextChangeWatcher(1));
        editText2.addTextChangedListener(new MyTextChangeWatcher(2));
        editText3.addTextChangedListener(new MyTextChangeWatcher(3));
        editText4.addTextChangedListener(new MyTextChangeWatcher(4));
        editText5.addTextChangedListener(new MyTextChangeWatcher(5));
        editText6.addTextChangedListener(new MyTextChangeWatcher(6));

        // del 监听,输入焦点前移
        editText1.setOnKeyListener(keyListener);
        editText2.setOnKeyListener(keyListener);
        editText3.setOnKeyListener(keyListener);
        editText4.setOnKeyListener(keyListener);
        editText5.setOnKeyListener(keyListener);
        editText6.setOnKeyListener(keyListener);
        new Utils(this).showIMM();
//        ShowKeyboard(editText1);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:CodeUnlockActivity.java

示例14: AfcSearchView

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * Creates new instance.
 * 
 * @param context
 *            {@link Context}.
 * @param attrs
 *            {@link AttributeSet}.
 */
public AfcSearchView(Context context, AttributeSet attrs) {
    super(context, attrs);

    /*
     * LOADS LAYOUTS
     */

    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.afc_widget_search_view, this, true);

    mButtonSearch = findViewById(R.id.afc_widget_search_view_button_search);
    mTextSearch = (EditText) findViewById(R.id.afc_widget_search_view_textview_search);
    mButtonClear = findViewById(R.id.afc_widget_search_view_button_clear);

    /*
     * ASSIGNS LISTENERS & ATTRIBUTES
     */

    mButtonSearch.setOnClickListener(mButtonSearchOnClickListener);
    mTextSearch.addTextChangedListener(mTextSearchTextWatcher);
    mTextSearch.setOnKeyListener(mTextSearchOnKeyListener);
    mTextSearch
            .setOnEditorActionListener(mTextSearchOnEditorActionListener);
    mButtonClear.setOnClickListener(mButtonClearOnClickListener);

    /*
     * LOADS ATTRIBUTES
     */

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.AfcSearchView);

    setDelayTimeSubmission(a.getInt(
            R.styleable.AfcSearchView_delayTimeSubmission, 0));
    updateViewsVisibility(
            a.getBoolean(R.styleable.AfcSearchView_iconified, true), false);
    setClosable(a.getBoolean(R.styleable.AfcSearchView_closable, true));
    setEnabled(a.getBoolean(R.styleable.AfcSearchView_enabled, true));
    mTextSearch.setHint(a.getString(R.styleable.AfcSearchView_hint));

    a.recycle();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:52,代码来源:AfcSearchView.java

示例15: onStart

import android.widget.EditText; //导入方法依赖的package包/类
/**
 * Invoked whenever the activity starts
 */
@Override
public void onStart() {
    super.onStart();

    // Retrieve events
    events.clear();
    UserAccount currentUser = HabitUpApplication.getCurrentUser();
    events.addAll(currentUser.getEventList().getEvents());
    // Sort by completedate
    Collections.sort(events);

    eventAdapter = new EventListAdapter(this, events);
    eventListView.setAdapter(eventAdapter);

    eventAdapter.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            eventAdapter.setPosition(eventListView.getChildAdapterPosition(v));
            return false;
        }
    });

    eventAdapter.setOnItemClickListener(new EventListAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View itemView, int pos) {
            position = pos;
            eventAdapter.setPosition(eventListView.getChildAdapterPosition(itemView));
            goToEditActivity(VIEW_EVENT);
        }
    });

    // Display if there are no events
    if (events.size() == 0) {
        TextView subHeading = (TextView) findViewById(R.id.select_event);
        subHeading.setText("You currently have no habit events.");
    }

    habitTypes = currentUser.getHabitList().getHabits();

    // Set up habit type filter spinner
    habitSpinner = (Spinner) findViewById(R.id.filter_habit_spinner);
    final ArrayAdapter<String> habitAdapter = new ArrayAdapter<>(this, R.layout.habit_spinner);
    habitAdapter.add("All Habit Types");
    // Set up habit types list
    habitTypes = currentUser.getHabitList().getHabits();

    // Populate spinner with habit type names
    for (Habit habit : habitTypes) {
        habitAdapter.add(habit.getHabitName());
    }
    habitSpinner.setAdapter(habitAdapter);

    // Spinner select
    habitSpinner.setOnItemSelectedListener(spinnerListener);

    commentFilter = (EditText) findViewById(R.id.filter_comment);
    commentFilter.setOnKeyListener(cFilter);

    // Highlight events row in drawer
    navigationView.setCheckedItem(R.id.events);
}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:65,代码来源:ViewHabitEventActivity.java


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