當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。