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:cn.ucai.fulicenter.activity.GroupsActivity.java
private void setGroupListViewTouchListener() { groupListView.setOnTouchListener(new OnTouchListener() { @Override/*from w w w . jav a2s.c o m*/ public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:com.lykj.weixun.ui.chat.ui.GroupsActivity.java
@Override public void initView() { initHeaderBack(R.string.groups_title, 0); instance = this; inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); grouplist = EMClient.getInstance().groupManager().getAllGroups(); groupListView = (ListView) findViewById(R.id.list); //show group list groupAdapter = new GroupAdapter(this, 1, grouplist); groupListView.setAdapter(groupAdapter); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override//from ww w .j a va 2s . com public void onRefresh() { new Thread() { @Override public void run() { try { EMClient.getInstance().groupManager().getJoinedGroupsFromServer(); handler.sendEmptyMessage(0); } catch (HyphenateException e) { e.printStackTrace(); handler.sendEmptyMessage(1); } } }.start(); } }); groupListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(GroupsActivity.this, ChatActivity.class); intent.putExtra("chatType", Constant.CHATTYPE_GROUP); intent.putExtra("userId", groupAdapter.getItem(position - 1).getGroupId()); startActivityForResult(intent, 0); } }); groupListView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:com.example.Bama.chat.chatuidemo.activity.ChatHistoryFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); errorItem = (RelativeLayout) getView().findViewById(R.id.rl_error_item); errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg); // contact list contactList = HCApplication.getInstance().getContactList(); listView = (ListView) getView().findViewById(R.id.list); adapter = new ChatHistoryAdapter(getActivity(), 1, loadUsersWithRecentChat()); // adapter//from w ww. j a va2 s . co m listView.setAdapter(adapter); final String st = getResources().getString(R.string.Cant_chat_with_yourself); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMContact emContact = adapter.getItem(position); if (adapter.getItem(position).getUsername().equals(HCApplication.getInstance().getUserName())) Toast.makeText(getActivity(), st, Toast.LENGTH_SHORT).show(); else { // ?? Intent intent = new Intent(getActivity(), ChatActivity.class); if (emContact instanceof EMGroup) { //it is group chat intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); intent.putExtra("groupId", ((EMGroup) emContact).getGroupId()); } else { //it is single chat intent.putExtra("userId", emContact.getUsername()); } startActivity(intent); } } }); // ?? registerForContextMenu(listView); 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; } }); // ? query = (EditText) getView().findViewById(R.id.query); // ?button 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(); } }); }
From source file:com.xiaoyu.DoctorHelp.chat.chatuidemo.activity.ChatHistoryFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); errorItem = (RelativeLayout) getView().findViewById(R.id.rl_error_item); errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg); // contact list contactList = HCApplicaton.getInstance().getContactList(); listView = (ListView) getView().findViewById(R.id.list); adapter = new ChatHistoryAdapter(getActivity(), 1, loadUsersWithRecentChat()); // adapter/* www.ja v a2s .co m*/ listView.setAdapter(adapter); final String st = getResources().getString(R.string.Cant_chat_with_yourself); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMContact emContact = adapter.getItem(position); if (adapter.getItem(position).getUsername().equals(HCApplicaton.getInstance().getUserName())) Toast.makeText(getActivity(), st, Toast.LENGTH_SHORT).show(); else { // ?? Intent intent = new Intent(getActivity(), ChatActivity.class); if (emContact instanceof EMGroup) { //it is group chat intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); intent.putExtra("groupId", ((EMGroup) emContact).getGroupId()); } else { //it is single chat intent.putExtra("userId", emContact.getUsername()); } startActivity(intent); } } }); // ?? registerForContextMenu(listView); 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; } }); // ? query = (EditText) getView().findViewById(R.id.query); // ?button 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(); } }); }
From source file:com.android.idearse.Login.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login);//from w ww. j a va2 s . c o m getWindow().getAttributes().windowAnimations = R.style.Fade; preferences = PreferenceManager.getDefaultSharedPreferences(this); loadima = (ImageView) findViewById(R.id.loading); rotation = AnimationUtils.loadAnimation(getApplicationContext(), R.drawable.rotate_loading); rotation.setRepeatCount(Animation.INFINITE); ActionBar actionBar = getSupportActionBar(); setTitle(""); getSupportActionBar().setIcon(R.drawable.title_logo); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME); username = (EditText) findViewById(R.id.username); password = (EditText) findViewById(R.id.password); preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String user = preferences.getString("user", ""); String pass = preferences.getString("password", ""); username.setText(user); password.setText(pass); error_msg = (TextView) findViewById(R.id.error_msg); Button login = (Button) findViewById(R.id.login_btn); final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbtn); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { SharedPreferences.Editor editor = preferences.edit(); editor.putString("user", ""); editor.putString("password", ""); editor.commit(); username.setText(""); password.setText(""); } } }); if (user.length() != 0 && pass.length() != 0) { checkBox.setChecked(true); } login.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); if (username.length() == 0 || password.length() == 0) { error_msg.setText("Completa los campos"); error_msg.setVisibility(View.VISIBLE); } else { if (checkBox.isChecked()) { SharedPreferences.Editor editor = preferences.edit(); editor.putString("user", username.getText().toString()); editor.putString("password", password.getText().toString()); editor.commit(); } error_msg.setVisibility(View.GONE); loadima.startAnimation(rotation); loadima.setVisibility(View.VISIBLE); new LoginQuery().execute(getString(R.string.URL) + "conectar_mobil/user/login"); } } }); }
From source file:it.flaviomascetti.posture.PostureCheckFragment.java
@Override public void onStart() { super.onStart(); button = (Button) getActivity().findViewById(R.id.button_posture_check); if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { Log.e(getString(R.string.app_name), getString(R.string.error_write_permission)); ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_PERMISSION_REQUEST_SDCARD_WRITE); } else // if the permission is granted the button has to be enabled button.setEnabled(true);/*from w w w . j a va2 s .co m*/ button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Close the keyboard InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); // Retrieve the chest height from the editText EditText et = (EditText) getActivity().findViewById(R.id.edit_text_height); Integer height = Integer.parseInt(et.getText().toString()); if (height >= 1000 && height <= 2000) { chestHeight = height; et.setEnabled(false); // Check SdCard write permission Calendar c = Calendar.getInstance(); String name = String.valueOf(c.get(Calendar.YEAR)) + "-" + String.valueOf(c.get(Calendar.MONTH) + 1) + "-" + String.valueOf(c.get(Calendar.DAY_OF_MONTH)) + "-" + String.valueOf(c.get(Calendar.HOUR)) + "-" + String.valueOf(c.get(Calendar.MINUTE)) + "-" + String.valueOf(c.get(Calendar.SECOND)); // Create the results file file = createFile(folder, name + ".csv"); // Showing the start snackbar Snackbar.make(getActivity().findViewById(R.id.fragment_posture_test), R.string.snack_begin_test, Snackbar.LENGTH_LONG).show(); // Opening the output stream on the file try { bW = new BufferedWriter(new FileWriter(file, true)); bW.write("x\t" + // "y\t" + // Acceleration force "z\t" + // "x (mm)\t" + // Conversion of acceleration "z (mm)\t" + // force to mm "dCoP\t" + // Euclidean distance from actualCoP to previous CoP "lengthCoPPath"); // Summation of euclidean dist } catch (IOException e) { e.printStackTrace(); } testInProgress = false; // Delayed start of function testStart Handler handler = new Handler(); handler.postDelayed(testStart, 7000); // 7000 ms = 7 sec* // Make the Begin Button unclickable button.setEnabled(false); } else { // Showing the error snackbar Snackbar.make(getActivity().findViewById(R.id.fragment_posture_test), R.string.snack_error_height, Snackbar.LENGTH_LONG).show(); } } }); }
From source file:com.easemob.ui.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); 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);// w w w .java2s.co m contactList = new ArrayList<User>(); //?contactlist getContactList(); //adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar); 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 = MyApplication.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 { //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); }
From source file:com.aetherfoundry.searchers.BaseActivity.java
private void hideKeyboard() { runOnUiThread(new Runnable() { @Override//from w w w . j a va 2 s . c o m public void run() { if (getCurrentFocus() != null) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }); }
From source file:de.stadtrallye.rallyesoft.fragments.AssistantServerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.assistant_server_fragment, container, false); scrollView = (ScrollView) v.findViewById(R.id.scrollView); protocol = (Spinner) v.findViewById(R.id.protocol); edit_server = (EditText) v.findViewById(R.id.server); port = (EditText) v.findViewById(R.id.port); // path = (EditText) v.findViewById(R.id.path); port.setHint(Std.DEFAULT_PORT);//from w ww .ja v a2 s. c o m // path.setHint(Std.DEFAULT_PATH); // path.setOnEditorActionListener(new TextView.OnEditorActionListener() { // @Override // public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // if (actionId == EditorInfo.IME_ACTION_SEND) { // infoManager.startTest(); // } // return false; // } // }); btn_test = (Button) v.findViewById(R.id.test); btn_test.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View focus = getActivity().getCurrentFocus(); if (focus != null) { InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } infoManager.startTest(); } }); grp_server_info_manager = (ViewGroup) v.findViewById(R.id.info_manager); grp_server_info = (ViewGroup) v.findViewById(R.id.server_info); grp_server_loading = (ViewGroup) v.findViewById(R.id.loading); srv_image = (ImageView) v.findViewById(R.id.server_image); srv_name = (TextView) v.findViewById(R.id.server_name); srv_desc = (TextView) v.findViewById(R.id.server_desc); btn_next = (Button) v.findViewById(R.id.next); btn_next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { assistant.next(); } }); loader = ImageLoader.getInstance(); if (android.os.Build.VERSION.SDK_INT >= 11) setLayoutTransition((ViewGroup) v); return v; }
From source file:com.zhixu.icu.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); 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);/*from w ww. ja va 2 s . c om*/ contactList = new ArrayList<User>(); // ?contactlist getContactList(); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar); 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 = DemoApplication.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 { // 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); }