List of usage examples for android.widget SearchView setIconified
public void setIconified(boolean iconify)
From source file:org.transdroid.core.gui.search.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Manually insert the actions into the main torrent and secondary actions toolbars searchToolbar.inflateMenu(R.menu.activity_search); // Add an expandable SearchView to the action bar MenuItem item = menu.findItem(R.id.action_search); final SearchView searchView = new SearchView(getSupportActionBar().getThemedContext()); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryRefinementEnabled(true); searchView.setIconified(false); searchView.setIconifiedByDefault(false); MenuItemCompat.setActionView(item, searchView); searchMenu = item;//from ww w.j ava 2s . c o m return true; }
From source file:in.rab.ordboken.Ordboken.java
public SearchView initSearchView(Activity activity, Menu menu, String query, Boolean focus) { SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) activity.findViewById(R.id.mySearchView); searchView.setSearchableInfo(/*from ww w .j a v a2 s. c o m*/ searchManager.getSearchableInfo(new ComponentName(activity, MainActivity.class))); // Hack to get the magnifying glass icon inside the EditText searchView.setIconifiedByDefault(true); searchView.setIconified(false); // Hack to get rid of the collapse button searchView.onActionViewExpanded(); if (!focus) { searchView.clearFocus(); } // searchView.setSubmitButtonEnabled(true); searchView.setQueryRefinementEnabled(true); if (query != null) { searchView.setQuery(query, false); } return searchView; }
From source file:org.bwgz.quotation.activity.SearchResultsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu)); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); Intent intent = getIntent();/* w w w .j a v a2 s .c om*/ if (intent != null) { int type = intent.getIntExtra(EXTRA_SEARCH_TYPE, FreebaseSearch.SEARCH_TYPE_KEYWORD); Log.d(TAG, String.format("onCreateOptionsMenu - type: %s", type)); setSearchHint(menu, type); String query = intent.getStringExtra(SearchManager.QUERY); Log.d(TAG, String.format("onCreateOptionsMenu - query: %s", query)); if (query != null) { searchView.setIconified(true); searchView.setQuery(query, false); searchView.clearFocus(); } } return true; }
From source file:edu.ucsb.cs.cs185.inspirante.searchbyranking.SearchByRankingFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_search_by_ranking, container, false); final SearchView searchView = (SearchView) rootView.findViewById(R.id.search_by_ranking_search_view); int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); EditText searchEditText = (EditText) searchView.findViewById(id); searchEditText.setTextColor(Color.GRAY); searchEditText.setHintTextColor(Color.GRAY); searchView.setOnQueryTextListener(searchViewListener); searchView.setMaxWidth(Integer.MAX_VALUE); searchView.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a va 2 s .com public void onClick(View view) { searchView.setFocusable(true); searchView.setIconified(false); searchView.requestFocusFromTouch(); } }); mInspireRecyclerView = (RecyclerView) rootView.findViewById(R.id.search_rv); mInspireRecyclerView.setHasFixedSize(true); mInspireRecyclerView.setNestedScrollingEnabled(false); frequentTags = ItemCards.getInstance(getContext()).getFrequentTags(); mInspireAdapter = new RankByTagAdapter(getContext(), this, frequentTags); mInspireAdapter.setHasStableIds(true); mLayoutManager = new LinearLayoutManager(getContext()); mLayoutManager.setItemPrefetchEnabled(true); mInspireRecyclerView.setLayoutManager(mLayoutManager); mInspireAdapter.setOnItemClickListener(new RankByTagAdapter.OnRecyclerViewItemClickListener() { @Override public void onItemClick(View view, int position) { TextView tv = (TextView) view; Intent intent = new Intent(getActivity(), TagAndImagesActivity.class); intent.putExtra("TAG", tv.getText()); startActivity(intent); } }); ItemCards itemCards = ItemCards.getInstance(getContext()); itemCards.setAdapter(mInspireAdapter); mInspireRecyclerView.setAdapter(mInspireAdapter); mInspireAdapter.notifyDataSetChanged(); // Set Tag recycler view mTagRecyclerView = (RecyclerView) rootView.findViewById(R.id.search_tags_rv); mTagRecyclerView.setHasFixedSize(true); mTagRecyclerView.setNestedScrollingEnabled(false); mTagsAdapter = new TagsAdapter(getContext(), frequentTags); mTagsAdapter.setHasStableIds(true); RecyclerView.LayoutManager tagsLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); tagsLayoutManager.setItemPrefetchEnabled(true); mTagRecyclerView.setLayoutManager(tagsLayoutManager); mTagsAdapter.setOnItemClickListener(new TagsAdapter.OnRecyclerViewItemClickListener() { @Override public void onItemClick(View view, int position) { String tag = mTagsAdapter.getTag(position); searchViewListener.onQueryTextChange(tag); //searchView.setFocus searchView.setQuery(tag, true); searchView.setIconified(false); searchView.clearFocus(); mLayoutManager.scrollToPosition(0); } }); mTagRecyclerView.setAdapter(mTagsAdapter); mTagsAdapter.notifyDataSetChanged(); return rootView; }
From source file:edu.sfsu.csc780.chathub.ui.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DesignUtils.applyColorfulTheme(this); setContentView(R.layout.activity_main); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Set default username is anonymous. mUsername = ANONYMOUS;/* w w w.j a va 2 s . c om*/ //Initialize Auth mAuth = FirebaseAuth.getInstance(); mUser = mAuth.getCurrentUser(); if (mUser == null) { startActivity(new Intent(this, SignInActivity.class)); finish(); return; } else { mUsername = mUser.getDisplayName(); if (mUser.getPhotoUrl() != null) { mPhotoUrl = mUser.getPhotoUrl().toString(); } } AudioUtil.startAudioListener(this); mSinchClient = Sinch.getSinchClientBuilder().context(getApplicationContext()) .applicationKey(APIKeys.SINCH_API_KEY).applicationSecret(APIKeys.SINCH_APP_SECRET) .environmentHost("sandbox.sinch.com") .userId(UserUtil.parseUsername(mSharedPreferences.getString("username", "anonymous"))).build(); mSinchClient.setSupportCalling(true); mCurrentChannel = mSharedPreferences.getString("currentChannel", "general"); mCurrChanTextView = (TextView) findViewById(R.id.currentChannelName); mCurrChanTextView.setText(ChannelUtil.getChannelDisplayName(mCurrentChannel, this)); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); // Initialize ProgressBar and RecyclerView. mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setStackFromEnd(true); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mChannelAdd = (RelativeLayout) findViewById(R.id.channelAdd); mToolBar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolBar); mToolBar.setTitleTextColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); mDrawerLayout.setStatusBarBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary)); mFirebaseAdapter = MessageUtil.getFirebaseAdapter(this, this, /* MessageLoadListener */ mLinearLayoutManager, mMessageRecyclerView, mImageClickListener); mMessageRecyclerView.setAdapter(mFirebaseAdapter); mProgressBar.setVisibility(ProgressBar.INVISIBLE); mMessageEditText = (EditText) findViewById(R.id.messageEditText); mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(MSG_LENGTH_LIMIT) }); mMessageEditText.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) { if (charSequence.toString().trim().length() > 0) { mSendButton.setEnabled(true); } else { mSendButton.setEnabled(false); } } @Override public void afterTextChanged(Editable editable) { } }); mSendButton = (FloatingActionButton) findViewById(R.id.sendButton); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Send messages on click. mMessageRecyclerView.scrollToPosition(0); ChatMessage chatMessage = new ChatMessage(mMessageEditText.getText().toString(), mUsername, mPhotoUrl, mCurrentChannel); MessageUtil.send(chatMessage, MainActivity.this); mMessageEditText.setText(""); } }); mImageButton = (ImageButton) findViewById(R.id.shareImageButton); mImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pickImage(); } }); mPhotoButton = (ImageButton) findViewById(R.id.cameraButton); mPhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dispatchTakePhotoIntent(); } }); mLocationButton = (ImageButton) findViewById(R.id.locationButton); mLocationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadMap(); } }); mChannelAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, ChannelSearchActivity.class); startActivityForResult(intent, REQUEST_NEW_CHANNEL); } }); SearchView jumpSearchView = (SearchView) findViewById(R.id.jumpSearch); int id = jumpSearchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); TextView textView = (TextView) jumpSearchView.findViewById(id); textView.setTextColor(Color.WHITE); textView.setHintTextColor(Color.WHITE); jumpSearchView.setIconified(false); jumpSearchView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(MainActivity.this, "Not implemented", Toast.LENGTH_SHORT).show(); } }); mNavRecyclerView = (RecyclerView) findViewById(R.id.navRecyclerView); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); mNavRecyclerView.setLayoutManager(linearLayoutManager); mNavRecyclerView.setAdapter(ChannelUtil.getFirebaseAdapterForUserChannelList(mChannelClickListener, mAuth.getCurrentUser().getDisplayName())); RecyclerView userListRecyclerView = (RecyclerView) findViewById(R.id.userListRecyclerView); LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(this); userListRecyclerView.setLayoutManager(linearLayoutManager2); userListRecyclerView.setAdapter(UserUtil.getFirebaseAdapterForUserList(mChannelClickListener)); Button voiceCallButton = (Button) findViewById(R.id.voiceCall); mCallProgressTextView = (TextView) findViewById(R.id.callinprogress); final AudioManager audioManager = (AudioManager) getApplicationContext() .getSystemService(Context.AUDIO_SERVICE); voiceCallButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { CallClient callClient = mSinchClient.getCallClient(); if (canCall) { call = callClient.callConference("General"); call.addCallListener(new CallListener() { @Override public void onCallProgressing(Call call) { //setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); audioManager.adjustStreamVolume(AudioManager.STREAM_VOICE_CALL, AudioManager.ADJUST_RAISE, 10); Log.d("Call", "Call progressing"); } @Override public void onCallEstablished(Call call) { setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); mCallProgressTextView.setVisibility(View.VISIBLE); Log.d("Call", "Calling now"); } @Override public void onCallEnded(Call call) { setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); Log.d("Call", "Stopped calling"); mCallProgressTextView.setVisibility(View.INVISIBLE); } @Override public void onShouldSendPushNotification(Call call, List<PushPair> list) { Log.d("Call", "Push"); } }); } } }); Button endCallButton = (Button) findViewById(R.id.endCall); endCallButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (call != null) { call.hangup(); call = null; } } }); }
From source file:co.tinode.tindroid.ContactsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Inflate the menu items inflater.inflate(R.menu.menu_contacts, menu); // Locate the search item MenuItem searchItem = menu.findItem(R.id.menu_search); // Retrieves the system search manager service final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); // Retrieves the SearchView from the search menu item final SearchView searchView = (SearchView) searchItem.getActionView(); // searchView.setFocusable(true); // Assign searchable info to SearchView searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); // Set listeners for SearchView searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//from w w w . ja v a 2s . co m public boolean onQueryTextSubmit(String queryText) { // Nothing needs to happen when the user submits the search string return true; } @Override public boolean onQueryTextChange(String newText) { // Called when the action bar search text has changed. Updates // the search filter, and restarts the loader to do a new query // using the new search string. String newFilter = !TextUtils.isEmpty(newText) ? newText : null; // Don't do anything if the filter is empty if (mSearchTerm == null && newFilter == null) { return true; } // Don't do anything if the new filter is the same as the current filter if (mSearchTerm != null && mSearchTerm.equals(newFilter)) { return true; } // Updates current filter to new filter mSearchTerm = newFilter; // Restarts the loader. This triggers onCreateLoader(), which builds the // necessary content Uri from mSearchTerm. getLoaderManager().restartLoader(ContactsQuery.CORE_QUERY_ID, null, mContactsLoaderCallback); return true; } }); MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem menuItem) { Log.d(TAG, "EXPAND onMenuItemActionCollapse"); searchView.setIconified(false); searchView.requestFocusFromTouch(); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem menuItem) { Log.d(TAG, "COLLAPSE onMenuItemActionCollapse"); searchView.clearFocus(); // When the user collapses the SearchView the current search string is // cleared and the loader restarted. if (!TextUtils.isEmpty(mSearchTerm)) { onSelectionCleared(); } mSearchTerm = null; getLoaderManager().restartLoader(ContactsQuery.CORE_QUERY_ID, null, mContactsLoaderCallback); return true; } }); if (mSearchTerm != null) { // If search term is already set here then this fragment is // being restored from a saved state and the search menu item // needs to be expanded and populated again. // Stores the search term (as it will be wiped out by // onQueryTextChange() when the menu item is expanded). final String savedSearchTerm = mSearchTerm; // Expands the search menu item searchItem.expandActionView(); // Sets the SearchView to the previous search string searchView.setQuery(savedSearchTerm, false); } }