List of usage examples for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS
int HIDE_NOT_ALWAYS
To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.
Click Source Link
From source file:org.imdea.panel.InputFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_input, container); Tag = getArguments().getString("Tag"); mEditText = (EditText) view.findViewById(R.id.txt_your_name); btn = (Button) view.findViewById(R.id.send_btn); getDialog().setTitle("New Tag"); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String inputText = mEditText.getText().toString(); if (inputText.isEmpty()) { Toast toast = Toast.makeText(getActivity().getApplicationContext(), "You didnt write anything!", Toast.LENGTH_SHORT); toast.show();/*from w w w . j a v a 2 s . c o m*/ dismiss(); } else { if (inputText.indexOf(' ') != -1) { Toast toast = Toast.makeText(getActivity().getApplicationContext(), "You cannot use whitespaces on a Tag", Toast.LENGTH_SHORT); toast.show(); } else { if (!DBHelper.existTag(Global.db, mEditText.getText().toString())) { // If the tag does not exists DBHelper.newTag(Global.db, inputText); TagsFragment.refresh(); } else { Toast toast = Toast.makeText(getActivity().getApplicationContext(), "Tag already exists", Toast.LENGTH_SHORT); toast.show(); } } } InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); dismiss(); } }); return view; }
From source file:dev.drsoran.moloko.util.UIUtils.java
public final static void hideSoftInput(Context context, IBinder windowToken) { if (windowToken != null) { final InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS); }//from w w w . j a v a2s. com } }
From source file:org.deviceconnect.android.deviceplugin.irkit.settings.fragment.IRKitCreateVirtualDeviceDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View dialogView = inflater.inflate(R.layout.dialog_virtual_device, null); final EditText deviceNameLbl = (EditText) dialogView.findViewById(R.id.device_name); deviceNameLbl.setText(getArguments().getString(KEY_CATEGORY)); deviceNameLbl.addTextChangedListener(mWatchHandler); deviceNameLbl.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override// w w w . j a va 2 s .c o m public void onFocusChange(final View v, final boolean hasFocus) { if (!hasFocus) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }); TextView serviceIdLbl = (EditText) dialogView.findViewById(R.id.service_id); serviceIdLbl.setText(getArguments().getString(KEY_VIRTUAL_ID)); TextView deviceCategoryLbl = (TextView) dialogView.findViewById(R.id.device_category); deviceCategoryLbl.setText(getArguments().getString(KEY_CATEGORY)); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.virtual_device_title); builder.setView(dialogView); builder.setPositiveButton(R.string.virtual_device_create, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { saveVirtualDeviceData(deviceNameLbl.getText().toString()); dialog.dismiss(); } }); builder.setNegativeButton(R.string.virtual_device_delete_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); return builder.create(); }
From source file:com.example.reabar.wimc.Fragments.ManageMyCarsScreenFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_manage_my_cars_screen, container, false); fragmentCommunicator = (FragmentCommunicator) getActivity(); if (cars == null) { cars = new ArrayList<>(); }/*from ww w . j av a2 s .co m*/ Button addNewCarButton = (Button) view.findViewById(R.id.newCarButton); TextView title = (TextView) view.findViewById(R.id.logoTextManageMyCars); Typeface english = Typeface.createFromAsset(getActivity().getAssets(), "KOMIKAX_.ttf"); // create a typeface from the raw ttf Typeface hebrew = Typeface.createFromAsset(getActivity().getAssets(), "OpenSansHebrew-Bold.ttf"); // create a typeface from the raw ttf if (Locale.getDefault().getDisplayLanguage().equals("")) { addNewCarButton.setTypeface(hebrew); title.setTypeface(hebrew); } else { addNewCarButton.setTypeface(english); title.setTypeface(english); } progressBar = (ProgressBar) view.findViewById(R.id.mainProgressBar); progressBar.setVisibility(View.VISIBLE); carCompanyInput = (EditText) view.findViewById(R.id.carCompanyInput); carColorInput = (EditText) view.findViewById(R.id.carColorInput); carLicenseInput = (EditText) view.findViewById(R.id.carLicenseInput); carModelInput = (EditText) view.findViewById(R.id.carModelInput); addNewCarButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //hide keyboard after click InputMethodManager inputManager = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); if (carCompanyInput.getText().toString().matches("") || carColorInput.getText().toString().matches("") || carLicenseInput.getText().toString().matches("") || carModelInput.getText().toString().matches("")) { Toast.makeText(MyApplication.getAppActivity(), "You must fill all the information about the new car", Toast.LENGTH_SHORT).show(); } else { Car newCar = new Car(carLicenseInput.getText().toString(), carColorInput.getText().toString(), carModelInput.getText().toString(), carCompanyInput.getText().toString(), Model.getInstance().getCurrentUser().getEmail()); Model.getInstance().addCarToDB(newCar, new Model.SyncListener() { @Override public void isSuccessful(boolean success) { if (success) { Toast.makeText(MyApplication.getAppActivity(), "New Car Added!", Toast.LENGTH_SHORT) .show(); fragmentCommunicator.passString("HomeScreenFragment"); } } @Override public void failed(String message) { Toast.makeText(MyApplication.getAppActivity(), message, Toast.LENGTH_SHORT).show(); } @Override public void passData(Object data) { } }); } } }); carsList = (ListView) view.findViewById(R.id.carsListView); Model.getInstance().getOwnedCars(Model.getInstance().getCurrentUser().getEmail(), new Model.SyncListener() { @Override public void passData(Object allCars) { cars = (ArrayList) allCars; progressBar.setVisibility(View.GONE); adapter.notifyDataSetChanged(); } @Override public void isSuccessful(boolean s) { } @Override public void failed(String s) { } }); adapter = new MyCarsAdapter(); carsList.setAdapter(adapter); carsList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Object[] data = new Object[] { cars.get(position) }; fragmentCommunicator.passData(data, "CarScreenFragment"); } }); return view; }
From source file:com.kytse.aria2remote.LoginFragment.java
private void attemptLogin() { InputMethodManager inputManager = (InputMethodManager) getContext() .getSystemService(Activity.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); if (mAuthTask != null) { return;// www.j a v a 2s.com } mEditTextUrl.setError(null); mEditTextSecret.setError(null); String url = mEditTextUrl.getText().toString(); String secret = mEditTextSecret.getText().toString(); boolean cancel = false; View focusView = null; if (TextUtils.isEmpty(url)) { mEditTextUrl.setError(getString(R.string.error_url_required)); focusView = mEditTextUrl; cancel = true; } if (cancel) { focusView.requestFocus(); } else { showProgress(true); mAuthTask = new UserLoginTask(url, secret); mAuthTask.execute((Void) null); } }
From source file:com.MyFunApp.NewFun.Activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) { // T??home???appcrash // fragment?? finish();//from w ww. j a v a2s.co m //startActivity(new Intent(this, LoginActivity.class)); return; } inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } setContentView(R.layout.activity_main); initViews(); //MobclickAgent.setDebugMode( true ); //MobclickAgent.updateOnlineConfig(this); if (getIntent().getBooleanExtra("conflict", false) && !isConflictDialogShow) { } // fragment??? // chatHistoryFragment = new ChatHistoryFragment(); // ?fragment /* chatHistoryFragment = new ChatAllHistoryFragment(); contactListFragment = new MyContactlistFragment(); settingFragment = new SettingsFragment(); MainFragment = new MainFragment(); fragments = new Fragment[] {contactListFragment , chatHistoryFragment,MainFragment, settingFragment }; // fragment getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment) .add(R.id.fragment_container, contactListFragment).hide(chatHistoryFragment).show(contactListFragment).commit(); */ }
From source file:info.xuluan.podcast.SearchActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_activity); setTitle(getResources().getString(R.string.title_channels)); mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings); setListAdapter(mAdapter);/*from ww w . j a v a2s.co m*/ getListView().setOnCreateContextMenuListener(this); mEditText = (EditText) findViewById(R.id.keywords); mEditText.addTextChangedListener(this); startInit(); Button next = (Button) findViewById(R.id.ButtonNext); next.setEnabled(false); next.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String str = "&start=" + mStart; String url = getUrl(); if (url != null) { start_search(url + str); } } }); ImageButton start = (ImageButton) findViewById(R.id.ButtonStart); start.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { InputMethodManager m = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); m.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); m.hideSoftInputFromInputMethod(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); String str = "&start=" + mStart; String url = getUrl(); if (url != null) { start_search(url + str); } } }); TabsHelper.setChannelTabClickListeners(this, R.id.channel_bar_search_button); }
From source file:org.openmidaas.app.activities.PushNotificationActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.push_register); isPhoneValid = false;//from www .j ava 2 s. co m //Get number from the SIM card if present phoneNumber = getPhoneNumberFromSIM(); //Set it to EditText if not null if (phoneNumber != null) { View tv = findViewById(R.id.edPushActivity); ((EditText) tv).setText(phoneNumber); } btnPositive = (Button) findViewById(R.id.btnOkayPushPhone); btnPositive.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { isPhoneValid = false; //Get the Number on click from EditText View tv = findViewById(R.id.edPushActivity); phoneNumber = ((EditText) tv).getText().toString(); if ((phoneNumber == null) || (phoneNumber.isEmpty())) { DialogUtils.showNeutralButtonDialog(PushNotificationActivity.this, "Error", "Phone Number cannot be empty."); } else { //Hide the keyboard InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); //parse the number to check the validity phoneUtil = PhoneNumberUtil.getInstance(); try { String phoneTest; if (phoneNumber.contains("+")) { phoneTest = phoneNumber; } else { phoneTest = "+" + phoneNumber; } phoneParsedNumber = phoneUtil.parse(phoneTest, null); isPhoneValid = phoneUtil.isValidNumber(phoneParsedNumber); // returns true or false } catch (NumberParseException e) { Logger.debug(getClass(), "NumberParseException was thrown: " + e.toString()); } if (isPhoneValid == true) { //valid phone // save phone number in shared preference SharedPreferences.Editor editor = getSharedPreferences( Constants.SharedPreferenceNames.PHONE_NUMBER_PUSH_SERVICE, MODE_PRIVATE).edit(); editor.putString("phoneNumberPush", phoneNumber); editor.commit(); try { /*Help to make sure the device is ready for using GCM, including whether or not it has the Google Services Framework*/ GCMRegistrar.checkDevice(PushNotificationActivity.this); // Check internet connection if (isNetworkAvailable() == false) { Logger.debug(getClass(), "Not connected to internet. Failed Registration."); DialogUtils.showNeutralButtonDialog(PushNotificationActivity.this, "Registration Failed", "Active internet connection is required for registering."); } else { // Register Local Broadcast Listener to receive messages. // We are registering an observer (mMessageReceiver) to receive Intents // with actions named "custom-event-name". Logger.debug(getClass(), "Registering the receiver"); LocalBroadcastManager.getInstance(PushNotificationActivity.this) .registerReceiver(mMessageReceiver, new IntentFilter( Constants.IntentActionMessages.LOCAL_BROADCAST_GCM_MESSAGE)); //Takes the sender ID and registers app to be able to receive messages sent by that sender. ID received in a callback in BroadCastReceiver GCMRegistrar.register(PushNotificationActivity.this, SENDER_ID); //Dialog started here and would be dismissed when its registered on server or there is an error. mProgressDialog.setTitle("Please Wait"); mProgressDialog .setMessage("Registering your number for push notification service..."); mProgressDialog.setCancelable(false); mProgressDialog.show(); } } catch (RuntimeException e) { //Device incompatibility message Logger.debug(getClass(), e + " Device is incompatible for using GCM services."); DialogUtils.showNeutralButtonDialog(PushNotificationActivity.this, "Registration Failed", "Unable to register to push message service. Device is incompatible for using GCM services."); } } else { //Invalid phone number message Logger.debug(getClass(), "Invalid phone number entered for push registration."); DialogUtils.showNeutralButtonDialog(PushNotificationActivity.this, "Invalid Phone Number", "Please enter a valid international phone number. Make sure you've entered the country code followed by phone number."); } } } }); btnClear = (Button) findViewById(R.id.btnClearPushPhone); btnClear.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //Clear the text to set it to default View ed = findViewById(R.id.edPushActivity); ((EditText) ed).setText(""); } }); }
From source file:org.imdea.panel.showMessages.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_messages); tag = getIntent().getExtras().getString("tag"); messages = DBHelper.recoverMessagesByTag(Global.db, tag); setTitle(tag);/*from w w w .ja v a 2 s .c o m*/ fm = getFragmentManager(); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayShowHomeEnabled(true); SP = PreferenceManager.getDefaultSharedPreferences(this); listv = (ListView) findViewById(R.id.listViewM); send_btn = (Button) findViewById(R.id.btnSend); text_field = (EditText) findViewById(R.id.inputMsg); send_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String text = text_field.getText().toString(); if (!text.isEmpty()) { text = text.replace("\n", " "); BtMessage item = new BtMessage(text, SP.getString("username_field", "anonymous")); Log.w("NEW MSG", item.toJson().toString()); item.isMine = true; item.setTag(tag); DBHelper.insertMessage(Global.db, item); text_field.setText(""); if (Global.mqtt) mqttService.sendToPeers(item); sendBroadcast(new Intent("org.imdea.panel.MESSAGE_WRITTEN")); TagsFragment.refresh(); } InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); refresh(); } }); adapter = new ItemAdapter(this, messages) { public void onEntrada(Object item, View view) { TextView text_msg = (TextView) view.findViewById(R.id.msg); text_msg.setText(((BtMessage) item).msg); TextView text_user = (TextView) view.findViewById(R.id.name); text_user.setText(((BtMessage) item).user); } }; listv.setAdapter(adapter); listv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final BtMessage listItem = (BtMessage) listv.getItemAtPosition(position); Log.i("TAG_FRAGMENT", "Long Click on " + listItem.toString()); AlertDialog.Builder builder = new AlertDialog.Builder(showMessages.this); final CharSequence[] shareItems = { "Delete", "Information" }; builder.setCancelable(true).setItems(shareItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (id == 0) { DBHelper.deleteMessage(Global.db, listItem); //Messages.deleteMessage(listItem); refresh(); } else { Intent intent = new Intent(getBaseContext(), InfoActivity.class); intent.putExtra("HASH", listItem.toHash()); startActivity(intent); } } }); /*builder.setCancelable(true).setPositiveButton("DELETE", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { DBHelper.deleteMessage(MainActivity.db,(BtMessage) listItem); refresh(); } });*/ AlertDialog alert = builder.create(); alert.show(); return false; } }); }
From source file:com.nextgis.metroaccess.ui.fragment.SelectStationListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.setRetainInstance(true); View view = inflater.inflate(R.layout.stationlist_fragment, container, false); m_oExpListView = (StationExpandableListView) view.findViewById(R.id.lvStationList); m_oExpListView.setFastScrollEnabled(true); m_oExpListView.setGroupIndicator(null); m_oExpListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { ((MetroApp) getActivity().getApplication()) .addEvent(Constants.SCREEN_SELECT_STATION + " " + getDirection(), Constants.PORTAL, mTab); final PortalItem selected = (PortalItem) m_oExpListAdapter.getChild(groupPosition, childPosition); SelectStationActivity parentActivity = (SelectStationActivity) getActivity(); parentActivity.finish(selected.GetStationId(), selected.GetId()); return true; }//from w w w .ja v a 2 s . c om }); m_oExpListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { InputMethodManager imm = (InputMethodManager) getActivity().getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); if (m_oExpListAdapter.getGroup(groupPosition).isSection()) { ((MetroApp) getActivity().getApplication()).addEvent( Constants.SCREEN_SELECT_STATION + " " + getDirection(), Constants.HEADER, mTab); int scrollTo = groupPosition; for (int i = 0; i < groupPosition; i++) if (m_oExpListView.isGroupExpanded(i)) scrollTo += m_oExpListAdapter.getChildrenCount(i); m_oExpListView.smoothScrollToPositionFromTop(scrollTo); } else if (((StationItem) m_oExpListAdapter.getGroup(groupPosition)).GetPortalsCount() == 0) Toast.makeText(getActivity(), getString(R.string.sNoPortals), Toast.LENGTH_SHORT).show(); return false; } }); m_oExpListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { @Override public void onGroupExpand(int i) { if (!m_oExpListAdapter.getGroup(i).isSection()) ((MetroApp) getActivity().getApplication()).addEvent( Constants.SCREEN_SELECT_STATION + " " + getDirection(), Constants.STATION_EXPAND, mTab); } }); m_oExpListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() { @Override public void onGroupCollapse(int i) { if (!m_oExpListAdapter.getGroup(i).isSection()) ((MetroApp) getActivity().getApplication()).addEvent( Constants.SCREEN_SELECT_STATION + " " + getDirection(), Constants.STATION_COLLAPSE, mTab); } }); return view; }