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:com.polito.dion.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); mETAddType = (EditText) rootView.findViewById(R.id.etAddType); mETAddCost = (EditText) rootView.findViewById(R.id.etAddCost); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override/*from w w w. j a va2s .c o m*/ protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { Author author = comment.getAuthor(); viewHolder.commentAuthor.setText(author.getFull_name()); GlideUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto); viewHolder.authorRef = author.getUid(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); viewHolder.commentAddType.setText(comment.getAddType()); viewHolder.commentAddCost.setText(comment.getAddCost()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); final Editable commentAddType = mETAddType.getText(); final Editable commentAddCost = mETAddCost.getText(); mEditText.setText(""); mETAddType.setText(""); mETAddCost.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Author author = new Author(user.getDisplayName(), user.getPhotoUrl().toString(), user.getUid()); Comment comment = new Comment(author, commentAddCost.toString(), commentAddType.toString(), commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:la.zmkm.agent.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;// w w w . jav 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<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 = 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); }
From source file:com.imalu.alyou.activity.GroupsActivity.java
public void generateList() { // grouplist = EMGroupManager.getInstance().getAllGroups(); groupListView = (ListView) findViewById(R.id.list); groupAdapter = new GroupAdapter(this, R.layout.row_group, AlUApplication.getGroups().getConversationGroupList()); groupListView.setAdapter(groupAdapter); groupListView.setOnItemClickListener(new OnItemClickListener() { @Override/* ww w . j a v a 2 s . c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if (position == groupAdapter.getCount() - 1) { // //? // startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0); // } else { //? Intent intent = new Intent(GroupsActivity.this, ChatActivity.class); // it is group chat intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); intent.putExtra("groupId", groupAdapter.getItem(position).getGroupKey()); intent.putExtra("groupName", groupAdapter.getItem(position).getGroupName()); startActivityForResult(intent, 0); // } } }); groupListView.setOnTouchListener(new 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; } }); ImageView addContactView = (ImageView) findViewById(R.id.iv_new_group); addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(GroupsActivity.this, NewGroupActivity.class)); } }); }
From source file:cn.kangeqiu.kq.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/* w ww . j ava 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); String strSearch = getResources().getString(R.string.search); query.setHint(strSearch); 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(); } }); // 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 = BaseApplication.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.lastsoft.plog.adapter.PlayerAdapter.java
public void playerPopup(View v, final int position) { try {//from w w w. ja va2s . c o m InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception ignored) { } PopupMenu popup = new PopupMenu(mActivity, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.player_overflow, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.view_plays: ((MainActivity) mActivity).openPlays("0^" + players.get(position).getId(), false, 8, mActivity.getString(R.string.title_players), currentYear); return true; case R.id.view_wins: ((MainActivity) mActivity).openPlays("0^" + players.get(position).getId(), false, 2, mActivity.getString(R.string.title_players), currentYear); return true; default: return false; } } }); popup.show(); }
From source file:com.example.Bama.chat.chatuidemo.activity.ContactlistFragment.java
private void initViewsAndListener(View view, Bundle savedInstanceState) { //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from w w w . j a v a2 s . co m inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) view.findViewById(R.id.list); sidebar = (Sidebar) view.findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) view.findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) view.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.ADD_FRIEND.equals(username)) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } else if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = HCApplication.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 { // 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; } }); registerForContextMenu(listView); }
From source file:com.youti.chat.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 w 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 = YoutiApplication.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 { // 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.xiaoyu.DoctorHelp.chat.chatuidemo.activity.ContactlistFragment.java
private void initViewsAndListener(View view, Bundle savedInstanceState) { //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from www . j a va2s .co m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) view.findViewById(R.id.list); sidebar = (Sidebar) view.findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) view.findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) view.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.ADD_FRIEND.equals(username)) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } else if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = HCApplicaton.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 { // 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; } }); registerForContextMenu(listView); }
From source file:com.grass.caishi.cc.frag.FriendsListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from w w w . j a v a 2 s . c o m inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); // listView.setFootRefresh(false); // listView.setPullLoadEnable(true); swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeLayout); // swipeRefreshLayout.setColorSchemeResources(R.color.swipe_color_1, // R.color.swipe_color_2, R.color.swipe_color_3, R.color.swipe_color_4); // swipeRefreshLayout.setSize(SwipeRefreshLayout.LARGE); // swipeRefreshLayout.setProgressBackgroundColor(R.color.swipe_background_color); swipeRefreshLayout.setProgressViewEndTarget(true, 100); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { ((MainActivity) getActivity()).refreshFriends(); } }); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); contactList = new ArrayList<User>(); // ?contactlist getContactList(); // 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 = MyApplication.getInstance().getContactList(false) .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.KEFU.equals(username)) { // ?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", Constant.KEFU) .putExtra("chatType", 0)); } else { startActivity(new Intent(getActivity(), Userinfo.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); isInitDone = true; refresh(); // // ? // 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.nxt.njitong.ContactlistActivity.java
public void initviews() { //super.onActivityCreated(savedInstanceState); //T??home???appcrash //if(savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) // return;/*from ww w .j a v a 2s .c o m*/ context = this; findViewById(R.id.back).setVisibility(View.VISIBLE); ((TextView) findViewById(R.id.message_title)).setText(getIntent().getStringExtra("type")); inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) findViewById(R.id.list); sidebar = (Sidebar) findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) findViewById(R.id.query); String strSearch = getResources().getString(R.string.search); query.setHint(strSearch); clearSearch = (ImageButton) 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(); } }); // adapter adapter = new ContactAdapter(context, 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 = DemoApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(context, NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(context, GroupsActivity.class)); } else { // demo?? startActivity(new Intent(context, ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new 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; } }); ImageView addContactView = (ImageView) findViewById(R.id.iv_new_contact); addContactView.setVisibility(View.GONE); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(context, AddContactActivity.class)); } }); registerForContextMenu(listView); }