List of usage examples for android.widget TextView getWindowToken
public IBinder getWindowToken()
From source file:Main.java
public static void hideKeys(Context context, TextView textView) { textView.setCursorVisible(false);/* w ww .j av a2 s . c o m*/ InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(textView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:com.commonsware.android.abf.ActionBarFragment.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event == null || event.getAction() == KeyEvent.ACTION_UP) { adapter.add(v.getText().toString()); v.setText(""); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); }// w w w . j ava 2 s. c o m return (true); }
From source file:radoslav.yordanov.quizgames.controller.QuizChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_quiz_choice, container, false); ImageView questionImg = (ImageView) rootView.findViewById(R.id.questionImg); imageLoader.displayImage(quizImage, questionImg, defaultOptions); Button selection1 = (Button) rootView.findViewById(R.id.selection1); Button selection2 = (Button) rootView.findViewById(R.id.selection2); Button selection3 = (Button) rootView.findViewById(R.id.selection3); Button selection4 = (Button) rootView.findViewById(R.id.selection4); Button[] selections = { selection1, selection2, selection3, selection4 }; final EditText answer = (EditText) rootView.findViewById(R.id.answer); if (quizChoices.size() == 4) { for (int i = 0; i < 4; i++) { selections[i].setText(quizChoices.get(i).getChoice()); selections[i].setTag(quizChoices.get(i).getIsRightChoice()); }//from ww w. ja v a 2 s . c o m } else { selection1.setVisibility(View.GONE); selection2.setVisibility(View.GONE); selection3.setVisibility(View.GONE); selection4.setVisibility(View.GONE); answer.setVisibility(View.VISIBLE); answer.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { ((QuizActivity) getActivity()).onSingleAnswerClick(quizChoices.get(0).getChoice(), answer.getText().toString()); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); return true; } return false; } }); } return rootView; }
From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java
public filter_dialog(Context cx, List<NameValuePair> data) { super(cx);/* w w w . j ava 2s . co m*/ this.cx = cx; this.webData = data; this.requestWindowFeature(Window.FEATURE_NO_TITLE); vocl = new View.OnClickListener() { public void onClick(View v) { onCheckboxClick(v); } }; maxLines = new OnEditorActionListener() { @Override public boolean onEditorAction(TextView tv, int action, KeyEvent key) { boolean handled = false; if (action == EditorInfo.IME_ACTION_DONE) { setMaxLines(tv.getText().toString()); tv.setText(getNamedData("iPage")); InputMethodManager imm = (InputMethodManager) tv.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); handled = true; } return handled; } }; rateListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { rateSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; licenseListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { licenseSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; placementListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { placementSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; }
From source file:com.esminis.server.library.activity.main.MainViewImpl.java
private void setupListeners(Activity activity) { viewDocumentRoot.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { presenter.showDocumentRootChooser(); }// w ww. j av a2 s. c om }); viewPort.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView text, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { final Activity activity = MainViewImpl.this.activity.get(); if (activity != null) { ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(text.getWindowToken(), 0); return true; } } return false; } }); viewPort.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void afterTextChanged(Editable text) { presenter.portModified(text.toString()); } }); activity.findViewById(R.id.start).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStart(); } }); activity.findViewById(R.id.stop).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStop(); } }); viewContainer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { removeFocus(); return true; } }); activity.findViewById(R.id.preloader_button_ok).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { presenter.requestPermission(); } }); buttonStart.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStart(); } }); buttonStop.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { presenter.serverStop(); } }); viewInstalledPackage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { presenter.requestPackageInstall(); } }); }
From source file:org.dharmaseed.android.NavigationActivity.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { Log.i("onEditorAction", v.getText().toString()); // Close keyboard InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); // Give up focus (which will invoke onFocusChange below to hide the cursor and keyboard) v.clearFocus();/*from w ww . java 2 s. c o m*/ // Search for talks meeting the new criteria updateDisplayedData(); // Scroll to the top of the list resetListToTop(); return false; }
From source file:com.unipiazza.material2stepslogin.fragments.FirstStepFragment.java
@Nullable @Override//w ww . j av a2 s .c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.first_login_view, null); email = (AutoCompleteTextView) view.findViewById(R.id.email); next = (Button) view.findViewById(R.id.buttonNext); progressBarFirst = (ProgressBar) view.findViewById(R.id.progressBarFirst); layoutFirst = (LinearLayout) view.findViewById(R.id.layoutFirst); logo = (ImageView) view.findViewById(R.id.logo); descriptionText = (TextView) view.findViewById(R.id.descriptionText); registerText = (TextView) view.findViewById(R.id.registerText); buttonRegistra = (Button) view.findViewById(R.id.buttonRegistra); progressBarFirst.setVisibility(View.GONE); if (mtsl != null) { view.setBackgroundColor(mtsl.getFirst_step_background_color()); logo.setImageResource(mtsl.getLogo()); descriptionText.setText(mtsl.getDescription()); if (mtsl.getRegister_description() != 0) registerText.setText(mtsl.getRegister_description()); if (mtsl.getRegister_description_text_color() != 0) registerText.setTextColor(mtsl.getRegister_description_text_color()); if (mtsl.getRegister_text() != 0) buttonRegistra.setText(mtsl.getRegister_text()); if (mtsl.getRegister_background() != 0) buttonRegistra.setBackgroundResource(mtsl.getRegister_background()); if (mtsl.getButton_register_text_color() != 0) buttonRegistra.setTextColor(mtsl.getButton_register_text_color()); if (mtsl.getEditText_email_text_color() != 0) email.setTextColor(mtsl.getEditText_email_text_color()); if (mtsl.getEdittext_email_background() != 0) email.setBackgroundResource(mtsl.getEdittext_email_background()); if (mtsl.getButton_next_background() != 0) next.setBackgroundResource(mtsl.getButton_next_background()); if (mtsl.getButton_next_text_color() != 0) next.setTextColor(mtsl.getButton_next_text_color()); if (mtsl.getDescription_text_color() != 0) descriptionText.setTextColor(mtsl.getDescription_text_color()); } email.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { next.performClick(); } return false; } }); checkAccountPermissions(); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progressBarFirst.setVisibility(View.VISIBLE); layoutFirst.setVisibility(View.GONE); mListener.onNextClicked(email.getText().toString()); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } }); buttonRegistra.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onRegisterClicked(); } }); return view; }
From source file:se.toxbee.sleepfighter.activity.EditGPSFilterAreaActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { String name = this.printName(); if (Build.VERSION.SDK_INT >= 11) { // add the custom view to the action bar. ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.gpsfilter_area_actionbar); actionBar.setDisplayOptions(//from w w w. j a v a 2s . c om ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM); View customView = actionBar.getCustomView(); // Setup edit name component. EditText editNameView = (EditText) customView.findViewById(R.id.edit_gpsfilter_area_title_edit); editNameView.setText(name); editNameView.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { area.setName(GPSFilterTextUtils.printName(getResources(), v.getText().toString())); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); return false; } }); editNameView.clearFocus(); // Setup enabled switch. CompoundButton activatedSwitch = (CompoundButton) customView .findViewById(R.id.edit_gpsfilter_area_toggle); activatedSwitch.setChecked(this.area.isEnabled()); activatedSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { area.setEnabled(isChecked); } }); } else { this.setTitle(name); } }
From source file:com.google.android.apps.flexbox.FlexItemEditFragment.java
private void setNextFocusesOnEnterDown(final TextView... textViews) { // This can be done by setting android:nextFocus* as in // https://developer.android.com/training/keyboard-input/navigation.html // But it requires API level 11 as a minimum sdk version. To support the lower level devices, // doing it programatically. for (int i = 0; i < textViews.length; i++) { final int index = i; textViews[index].setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override//from www. j a v a 2 s . co m public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE || (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { if (index + 1 < textViews.length) { textViews[index + 1].requestFocus(); } else if (index == textViews.length - 1) { InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0); } } return true; } }); // Suppress the key focus change by KeyEvent.ACTION_UP of the enter key textViews[index].setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP; } }); } }
From source file:info.staticfree.android.units.Units.java
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { switch (v.getId()) { case R.id.want: go();//from www . j a v a 2 s . co m final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); return true; } return false; }