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.sirimangalo.meditationplus.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); context = this; prefs = PreferenceManager.getDefaultSharedPreferences(this); postTask = new PostTaskRunner(postHandler, this); // Create a new service client and bind our activity to this service scheduleClient = new ScheduleClient(this); scheduleClient.doBindService();/*from ww w . j av a 2 s . c o m*/ mAlarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mNM = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); setContentView(R.layout.activity_main); onlineList = (TextView) findViewById(R.id.online); resultReceiver = new MyResultReceiver(null); // loading dialog loadingDialog = new ProgressDialog(this); loadingDialog.setTitle(R.string.processing); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // close keyboard View view = getCurrentFocus(); if (view != null) { inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } // reset chat title if (position == 1 && newChats) { if (actionBar.getTabAt(1) != null) actionBar.getTabAt(1) .setText(getString(R.string.title_section2).toUpperCase(Locale.getDefault())); newChats = false; } currentPosition = position; actionBar.setSelectedNavigationItem(position); } }); mViewPager.setOffscreenPageLimit(2); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } username = prefs.getString("username", ""); loginToken = prefs.getString("login_token", ""); if (loginToken.equals("")) showLogin(); }
From source file:hobby.wei.c.framework.AbsActivity.java
protected void hideInputMethod() { IBinder windowToken = getWindow().getDecorView().getWindowToken(); if (windowToken != null) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS); }// ww w . j a v a2 s . c o m }
From source file:mobi.cangol.mobile.base.BaseFragmentActivity.java
@Override public void hideSoftInput() { InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); if (this.getCurrentFocus() != null) { imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*from w w w . j a va2 s .c o m*/ }
From source file:dong.lan.tuyi.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from w ww. j a v a 2s . co m inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); InputTools.HideKeyboard(query); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = TuApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } //else if(Constant.CHAT_ROBOT.equals(username))} else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); // ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // // ? // addContactView.setOnClickListener(new OnClickListener() { // // @Override // public void onClick(View v) { // startActivity(new Intent(getActivity(), AddContactActivity.class)); // } // }); registerForContextMenu(listView); progressBar = getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:cn.ucai.yizhesale.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;// ww w .j a v a 2 s .c om inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<EMUser>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? EMUser user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:color.kidpaint.com.kidpaintcolor.dialog.TextToolDialog.java
public void hideKeyboard() { InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mTextEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:com.easemob.chatui.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from ww w . jav a 2 s . c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { /** ?*/ User user = BeewayApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity( new Intent(getActivity(), com.easemob.chatui.activity.NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { /** ?*/ startActivity(new Intent(getActivity(), com.easemob.chatui.activity.GroupsActivity.class)); } else { /** */ startActivity(new Intent(getActivity(), UserDetailsActivity.class).putExtra("friendid", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); //contactSyncListener.onSyncSucess(true); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:app.abhijit.iter.MainActivity.java
private void setupAddStudentButton() { final Button addStudentButton = (Button) findViewById(R.id.student_add); addStudentButton.setOnClickListener(new View.OnClickListener() { @Override/*from ww w . j a v a 2 s . c om*/ public void onClick(View v) { EditText addStudentEditText = (EditText) findViewById(R.id.student_registration_number_input); String registrationNumber = addStudentEditText.getText().toString(); ((MainApplication) getApplication()).getStudentDataSource().select(registrationNumber); addStudentEditText.setText(""); InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow( getCurrentFocus() == null ? null : getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawers(); } }); }
From source file:jp.mau.twappremover.MainActivity.java
/** ?? */ private void setButton() { Button btn = (Button) findViewById(R.id.activity_main_btn_submit); btn.setOnClickListener(new OnClickListener() { @Override/*from w w w. ja va2 s.c o m*/ public void onClick(View v) { reset(); // ??? InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); if (_id.getText().length() < 1 || _pass.getText().length() < 1) { // ??????? } else { // ? loginTask(); } } }); }
From source file:com.gm.goldencity.util.Utils.java
/** * Hide keyboard of a View/* ww w . j a va 2 s. co m*/ * * @param context Application context * @param view Edit text or another view that you want hide the keyboard */ public static void hideKeyboard(Context context, @NonNull View view) { InputMethodManager inputMethodManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }