本文整理汇总了Java中android.widget.EditText.setOnEditorActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setOnEditorActionListener方法的具体用法?Java EditText.setOnEditorActionListener怎么用?Java EditText.setOnEditorActionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setOnEditorActionListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeResources
import android.widget.EditText; //导入方法依赖的package包/类
private void initializeResources() {
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.centered_app_title);
ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);
showButton = (ImageButton) findViewById(R.id.passphrase_visibility);
hideButton = (ImageButton) findViewById(R.id.passphrase_visibility_off);
visibilityToggle = (AnimatingToggle) findViewById(R.id.button_toggle);
passphraseText = (EditText) findViewById(R.id.passphrase_edit);
SpannableString hint = new SpannableString(" " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
passphraseText.setHint(hint);
okButton.setOnClickListener(new OkButtonClickListener());
showButton.setOnClickListener(new ShowButtonOnClickListener());
hideButton.setOnClickListener(new HideButtonOnClickListener());
passphraseText.setOnEditorActionListener(new PassphraseActionListener());
passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
EditorInfo.IME_ACTION_DONE);
}
示例2: onCreate
import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
searchText = (EditText) findViewById(R.id.editTextSearch);
clearButton = (ImageView) findViewById(R.id.imageButtonClear);
searchText.addTextChangedListener(this);
searchText.setOnEditorActionListener(this);
setSupportActionBar(toolbar);
records = new Records(this);
}
示例3: onCreateView
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_login, container, false);
usernameEditText = (EditText) v.findViewById(R.id.username);
usernameEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
boolean handled = false;
if (i == EditorInfo.IME_ACTION_NEXT) {
usernameEditText.clearFocus();
username = usernameEditText.getText().toString();
pager.setCurrentItem(2);
handled = true;
}
return handled;
}
});
return v;
}
示例4: onCreateView
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
chatSDKUiHelper = ChatSDKUiHelper.getInstance().get(getActivity());
View view = inflater.inflate(R.layout.chat_sdk_dialog_edit_text, container);
mEditText = (EditText) view.findViewById(R.id.et_enter);
getDialog().setTitle(dialogTitle);
// Show soft keyboard automatically
mEditText.requestFocus();
getDialog().getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
// Listen to Done press on the keyboard.
mEditText.setOnEditorActionListener(this);
return view;
}
示例5: setupEtMeasure
import android.widget.EditText; //导入方法依赖的package包/类
private void setupEtMeasure()
{
etMeasure=(EditText)findViewById(R.id.etMeasure);
etMeasure.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override public boolean onEditorAction(TextView edt, int actionId, KeyEvent key) {
boolean handled=false;
if(actionId==EditorInfo.IME_ACTION_DONE) {
setParameters();
metr.restartIfPlaying();
edt.clearFocus();
hideKeyboard();
handled=true;
}
return handled;
}
});
}
示例6: onCreate
import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_anagrams);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
AssetManager assetManager = getAssets();
try {
InputStream inputStream = assetManager.open("words.txt");
dictionary = new AnagramDictionary(new InputStreamReader(inputStream));
} catch (IOException e) {
Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
toast.show();
}
// Set up the EditText box to process the content of the box when the user hits 'enter'
final EditText editText = (EditText) findViewById(R.id.editText);
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setImeOptions(EditorInfo.IME_ACTION_GO);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_GO) {
processWord(editText);
handled = true;
}
return handled;
}
});
}
示例7: getEditText
import android.widget.EditText; //导入方法依赖的package包/类
/**
* Get the Edit Text for this fragment
*
* @param parent the view parent
* @return the {@link EditText}
*/
public EditText getEditText(@NonNull final View parent) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getEditText");
}
final EditText editText = (EditText) parent.findViewById(R.id.etCommand);
editText.setOnEditorActionListener(getParent());
editText.setImeActionLabel(getParent().getString(R.string.menu_run), EditorInfo.IME_ACTION_GO);
return editText;
}
示例8: FillView
import android.widget.EditText; //导入方法依赖的package包/类
FillView(@NonNull Context context, ConfigManager manager, OverlayCallback overlayCallback) {
super(context);
this.manager = manager;
this.overlayCallback = overlayCallback;
this.adapter = new Adapter(context, this);
final LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.view_autofill, this, true);
final ListView listView = findViewById(R.id.list_view);
listView.setAdapter(adapter);
final EditText nameTV = findViewById(R.id.name_tv);
nameTV.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
saveOption(nameTV.getText().toString());
presentOptions(manager.getOptions());
return true;
}
return false;
});
final View button = findViewById(R.id.add_button);
button.setOnClickListener(v -> {
saveOption(nameTV.getText().toString());
presentOptions(manager.getOptions());
});
nameTV.addTextChangedListener(new ButtonEnabler(button));
presentOptions(manager.getOptions());
}
示例9: init
import android.widget.EditText; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
// Load attributes
final TypedArray a = getContext().obtainStyledAttributes(
attrs, R.styleable.lingju, defStyle, 0);
LayoutInflater.from(getContext()).inflate(R.layout.search_online_box, this);
mLlRoot = findViewById(R.id.ll_root);
edit = (EditText) findViewById(R.id.sob_search_edit);
stateBt = (ImageButton) findViewById(R.id.sob_state_bt);
animate = AnimationUtils.loadAnimation(getContext(), R.anim.start_up_loading);
animate.setInterpolator(new LinearInterpolator());
drawable = (LevelListDrawable) stateBt.getDrawable();
edit.addTextChangedListener(searhWatcher);
edit.setOnEditorActionListener(editorActionListener);
edit.setOnClickListener(editorClickListener);
stateBt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (stateBt.getVisibility() == View.VISIBLE && drawable.getLevel() == 1) {
edit.setText("");
stateBt.setVisibility(View.INVISIBLE);
}
}
});
edit.setHint(a.getString(R.styleable.lingju_hint));
// edit.setHintTextColor(getResources().getColor(R.color.navi_search_box_color));
edit.setHintTextColor(a.getColor(R.styleable.lingju_hintColor, getResources().getColor(R.color.navi_search_box_color)));
edit.setTextColor(a.getColor(R.styleable.lingju_textColor, getResources().getColor(R.color.ksw_md_solid_disable)));
mLlRoot.setBackgroundColor(a.getColor(R.styleable.lingju_search_background, getResources().getColor(R.color.green_style)));
//edit.setTextSize(a.getFloat(com.android.internal.R.styleable.TextView_textSize,12));
a.recycle();
}
示例10: configLayoutComponents
import android.widget.EditText; //导入方法依赖的package包/类
private void configLayoutComponents() {
WearableRecyclerView recyclerView = (WearableRecyclerView) findViewById(R.id.wearable_recycler_view);
recyclerView.setHasFixedSize(true);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(mLayoutManager);
mAdapter = new RecyclerViewAdapter();
mAdapter.setListNote(myDataSet);
mAdapter.setListener(this);
recyclerView.setAdapter(mAdapter);
EditText editText = (EditText) findViewById(R.id.edit_text);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int action, KeyEvent keyEvent) {
if (action == EditorInfo.IME_ACTION_SEND) {
String text = textView.getText().toString();
if (!TextUtils.isEmpty(text)) {
Note note = createNote(null, text);
SharedPreferencesUtils.saveNote(note, textView.getContext());
updateData(note, Constants.ACTION_ADD);
textView.setText("");
return true;
}
}
return false;
}
});
}
示例11: onViewCreated
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
if (DBG) Log.d(TAG, "onViewCreated");
mListView = (ListView) mView.findViewById(R.id.list);
mListView.setOnItemClickListener(this);
mListView.setAdapter(mAdapter);
mSearchContainer = mView.findViewById(R.id.custom_search_container);
mProgressContainer = mView.findViewById(R.id.progress_group);
mResultContainer = mView.findViewById(R.id.search_results_group);
mMessage = (TextView) mView.findViewById(R.id.message);
mSearchButton = mView.findViewById(R.id.search);
mSearchButton.setOnClickListener(this);
mView.findViewById(R.id.cancel).setOnClickListener(this);
mSearchEdTxt = (EditText) mView.findViewById(R.id.custom_search_edittext);
mSearchEdTxt.setHint(R.string.video_info_custom_search_show_hint);
mSearchEdTxt.setOnEditorActionListener(this);
// limit the way the window is adjusted when softkeyboard is opened
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
setInfoItem((Base)getActivity().getIntent().getSerializableExtra(VideoInfoScraperActivity.EXTRA_SHOW));
// restore display state
setDisplayState(mDisplayState);
}
示例12: onCreateDialog
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.sync_custom_passphrase, null);
mEnterPassphrase = (EditText) view.findViewById(R.id.passphrase);
mConfirmPassphrase = (EditText) view.findViewById(R.id.confirm_passphrase);
mConfirmPassphrase.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
tryToSubmitPassphrase();
}
return false;
}
});
TextView instructionsView =
(TextView) view.findViewById(R.id.custom_passphrase_instructions);
instructionsView.setMovementMethod(LinkMovementMethod.getInstance());
instructionsView.setText(getInstructionsText());
AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
.setView(view)
.setTitle(R.string.sync_passphrase_type_custom_dialog_title)
.setPositiveButton(R.string.save, null)
.setNegativeButton(R.string.cancel, null)
.create();
dialog.getDelegate().setHandleNativeActionModesEnabled(false);
return dialog;
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:33,代码来源:PassphraseCreationDialogFragment.java
示例13: onCreate
import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.console);
// setTitle("Loopback test");
mReception = (EditText) findViewById(R.id.EditTextReception);
EditText Emission = (EditText) findViewById(R.id.EditTextEmission);
Emission.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
int i;
CharSequence t = v.getText();
char[] text = new char[t.length()];
for (i = 0; i < t.length(); i++) {
text[i] = t.charAt(i);
}
try {
mOutputStream.write(new String(text).getBytes());
mOutputStream.write('\n');
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
});
}
示例14: setupChat
import android.widget.EditText; //导入方法依赖的package包/类
private void setupChat() {
Log.d(TAG, "setupChat()");
// Initialize the array adapter for the conversation thread
mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
mConversationView = (ListView) findViewById(R.id.in);
mConversationView.setAdapter(mConversationArrayAdapter);
// Initialize the compose field with a listener for the return key
mOutEditText = (EditText) findViewById(R.id.edit_text_out);
mOutEditText.setOnEditorActionListener(mWriteListener);
// Initialize the send button with a listener that for click events
mSendButton = (Button) findViewById(R.id.button_send);
mSendButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Send a message using content of the edit text widget
TextView view = (TextView) findViewById(R.id.edit_text_out);
String message = view.getText().toString();
sendMessage(message);
}
});
// Initialize the BluetoothChatService to perform bluetooth connections
mChatService = new BluetoothChatService(this, mHandler);
// Initialize the buffer for outgoing messages
mOutStringBuffer = new StringBuffer("");
}
示例15: 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();
}