List of usage examples for android.graphics Color parseColor
@ColorInt public static int parseColor(@Size(min = 1) String colorString)
From source file:com.ds.avare.utils.FolderPreference.java
/** * //w w w. j ava 2 s . c o m */ private void loadFileList() { /* * Checks whether mPath exists */ if (mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String filename) { File sel = new File(dir, filename); /* * Filters based on whether the file is hidden or not, and is a folder */ return (!sel.isHidden()); } }; String[] fList = mPath.list(filter); if (fList == null) { fList = new String[0]; } mFileList = new Item[fList.length]; for (int i = 0; i < fList.length; i++) { mFileList[i] = new Item(fList[i], android.R.drawable.alert_light_frame); /* * Convert into file mPath */ File sel = new File(mPath, fList[i]); /* * Set drawables */ if (sel.isDirectory()) { if (sel.canWrite()) { mFileList[i].icon = android.R.drawable.ic_menu_save; } else { mFileList[i].icon = android.R.drawable.ic_lock_lock; } } /* * File is for information only */ else { mFileList[i].icon = android.R.drawable.alert_light_frame; } } if (!mFirstLevel) { Item temp[] = new Item[mFileList.length + 1]; for (int i = 0; i < mFileList.length; i++) { temp[i + 1] = mFileList[i]; } temp[0] = new Item(mContext.getString(R.string.Up), android.R.drawable.ic_menu_revert); mFileList = temp; } } if (mFileList == null) { return; } /* * Set the adapter with file list */ mAdapter = new ArrayAdapter<Item>(mContext, android.R.layout.select_dialog_item, android.R.id.text1, mFileList) { @Override public View getView(int position, View convertView, ViewGroup parent) { /* * creates view */ View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(android.R.id.text1); /* * put the image on the text view */ textView.setCompoundDrawablesWithIntrinsicBounds(mFileList[position].icon, 0, 0, 0); /* * add margin between image and text (support various screen */ textView.setCompoundDrawablePadding(10); textView.setTextColor(Color.parseColor("#FF71BC78")); return view; } }; /* * Show where we are */ mPathView.setText(mPath.getAbsolutePath()); }
From source file:me.willowcheng.makerthings.model.OpenHABWidget.java
public void setIconColor(String color) { try {/*from w w w . j a v a 2s.c o m*/ this.iconcolor = new Integer(Color.parseColor(fixColorName(color))); } catch (IllegalArgumentException e) { Log.e("OpenHABWidget", "Color was " + color); Log.e("OpenHABWidget", e.getMessage()); this.iconcolor = null; } }
From source file:com.android.yijiang.kzx.widget.PagerSlidingTabStrip.java
private void changeToChild(int position) { if (tabCount == 0) { return;//from ww w . j av a 2 s .c o m } // if(position!=mPageIndex){ // TextView childTextView=(TextView) tabsContainer.getChildAt(position); // TextView offsetTextView=(TextView) tabsContainer.getChildAt(mPageIndex); // //// childTextView.setTextColor(indicatorColor); //// offsetTextView.setTextColor(tabTextColor); // childTextView.setTextColor(Color.parseColor("#666666")); // childTextView.getPaint().setFakeBoldText(false); // offsetTextView.setTextColor(Color.parseColor("#666666")); // offsetTextView.getPaint().setFakeBoldText(false); // }else{ // TextView childTextView=(TextView) tabsContainer.getChildAt(position); //// childTextView.setTextColor(indicatorColor); // childTextView.setTextColor(Color.parseColor("#444444")); // childTextView.getPaint().setFakeBoldText(true); // } // for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tab = (TextView) v; if (position == i) { tab.setTextColor(Color.parseColor("#444444")); tab.setAlpha(1.0f); tab.getPaint().setFakeBoldText(true); } else { tab.setTextColor(Color.parseColor("#666666")); tab.setAlpha(0.7f); tab.getPaint().setFakeBoldText(false); } } } }
From source file:com.newtifry.android.SourceEditor2.java
@SuppressLint("NewApi") public void updateSourcecolor(String value) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { if (value.equals("default")) { sourceColorPreference.setSummary(getString(R.string.froyo_color_summary)); } else {// w ww . j a va2 s . c o m String hexColor = Integer.toHexString(Color.parseColor(value)); String html = "<font color=\"#" + hexColor.substring(hexColor.length() - 6, 8) + "\">" + getString(R.string.froyo_color_summary) + "</font>"; sourceColorPreference.setSummary(Html.fromHtml(html)); } return; } String uri = "drawable/icon_color_" + value; int imageResource = getResources().getIdentifier(uri, null, getPackageName()); Drawable icon = getResources().getDrawable(imageResource); sourceColorPreference.setIcon(icon); }
From source file:com.filemanager.free.fragments.preference_fragments.Preffrag.java
@Override public boolean onPreferenceClick(final Preference preference) { if (preferences != null) preferences.changed = 1;//w w w . j a v a2 s . c o m final MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity()); a.positiveText(R.string.cancel); a.title(R.string.choose_color); if (theme == 1) a.theme(Theme.DARK); a.autoDismiss(true); int fab_skin_pos = sharedPref.getInt("fab_skin_color_position", 1); int fab_skin = Color.parseColor(PreferenceUtils.getFabColor(fab_skin_pos)); a.positiveColor(fab_skin); a.neutralColor(fab_skin); a.neutralText(R.string.defualt); a.onNeutral(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { sharedPref.edit().remove(preference.getKey()); sharedPref.edit().apply(); } }); ColorAdapter adapter = null; String[] colors = PreferenceUtils.colors; List<String> arrayList = Arrays.asList(colors); switch (preference.getKey()) { case "skin": adapter = new ColorAdapter(getActivity(), arrayList, "skin_color_position", sharedPref.getInt("skin_color_position", 9)); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getResources().getString(R.string.confirm)); builder.setMessage(getResources().getString(R.string.themeRestart)); builder.setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { restartPC(getActivity()); } }); builder.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setCancelable(true); builder.show(); break; case "fab_skin": adapter = new ColorAdapter(getActivity(), arrayList, "fab_skin_color_position", fab_skin_pos); break; case "icon_skin": adapter = new ColorAdapter(getActivity(), arrayList, "icon_skin_color_position", sharedPref.getInt("icon_skin_color_position", 9)); break; case "zippath": zipPath(); break; case "extractpath": zipPath(); break; default: break; } if (!preference.getKey().equals("zippath") && !preference.getKey().equals("extractpath")) { @SuppressLint("InflateParams") GridView v = (GridView) getActivity().getLayoutInflater().inflate(R.layout.dialog_grid, null); v.setAdapter(adapter); a.customView(v, false); MaterialDialog x = a.build(); assert (adapter) != null; adapter.updateMatDialog(x); x.show(); } return false; }
From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java
@Override public void create() { try {/*from www . jav a 2 s.c o m*/ setContentView(R.layout.grouped_contacts_details); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } person = (Person) store.getSerializable("person"); if (person == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } setTopBarTitle(widget.getTitle()); Boolean single = currentIntent.getBooleanExtra("single", true); setTopBarLeftButtonTextAndColor( single ? getResources().getString(R.string.common_home_upper) : getResources().getString(R.string.common_back_upper), getResources().getColor(android.R.color.black), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); setTopBarTitleColor(getResources().getColor(android.R.color.black)); setTopBarBackgroundColor(Statics.color1); if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) { ImageView shareButton = (ImageView) getLayoutInflater() .inflate(R.layout.grouped_contacts_share_button, null); shareButton.setLayoutParams( new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density), (int) (39 * getResources().getDisplayMetrics().density))); shareButton.setColorFilter(Color.BLACK); setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share), new View.OnClickListener() { @Override public void onClick(View v) { DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder(); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) sharingDialogBuilder .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_TEXT, message); email.setType("message/rfc822"); startActivity(Intent.createChooser(email, getString(R.string.choose_email_client))); } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) sharingDialogBuilder .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); try { Utils.sendSms(ContactDetailsActivity.this, message); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT))) sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook, R.drawable.gc_add_to_contacts, true, new DialogSharing.Item.OnClickListener() { @Override public void onClick() { createNewContact(person.getName(), person.getPhone(), person.getEmail()); } }); showDialogSharing(sharingDialogBuilder.build()); } }); } boolean hasSchema = store.getBoolean("hasschema"); cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder(); contacts = person.getContacts(); if (widget.getTitle().length() > 0) { setTitle(widget.getTitle()); } root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root); if (hasSchema) { root.setBackgroundColor(Statics.color1); } else if (widget.isBackgroundURL()) { cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL()); File backgroundFile = new File(cacheBackgroundFile); if (backgroundFile.exists()) { root.setBackgroundDrawable( new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile)))); } else { BackgroundDownloadTask dt = new BackgroundDownloadTask(); dt.execute(widget.getBackgroundURL()); } } else if (widget.isBackgroundInAssets()) { AssetManager am = this.getAssets(); root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL()))); } if (contacts != null) { ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar); avatarImage.setImageResource(R.drawable.gc_profile_avatar); if (person.hasAvatar() && NetworkUtils.isOnline(this)) { avatarImage.setVisibility(View.VISIBLE); Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar) .dontAnimate().into(avatarImage); } else { avatarImage.setVisibility(View.VISIBLE); avatarImage.setImageResource(R.drawable.gc_profile_avatar); } String name = ""; neededContacts = new ArrayList<>(); for (Contact con : contacts) { if ((con.getType() == 5) || (con.getDescription().length() == 0)) { } else { if (con.getType() == 0) { name = con.getDescription(); } else neededContacts.add(con); } } if (neededContacts.isEmpty()) { handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA); return; } headSeparator = findViewById(R.id.gc_head_separator); bottomSeparator = findViewById(R.id.gc_bottom_separator); imageBottom = findViewById(R.id.gc_image_bottom_layout); personName = (TextView) findViewById(R.id.gc_details_description); if ("".equals(name)) personName.setVisibility(View.GONE); else { personName.setVisibility(View.VISIBLE); personName.setText(name); personName.setTextColor(Statics.color3); } if (Statics.isLight) { headSeparator.setBackgroundColor(Color.parseColor("#4d000000")); bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000")); } else { headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); } ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1); ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view); list.setDivider(null); ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this, R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1)); list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { listViewItemClick(position); } }); } if (widget.hasParameter("add_contact")) { HashMap<String, String> hm = new HashMap<>(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { hm.put("contactName", contacts.get(i).getDescription()); } break; case 1: { hm.put("contactNumber", contacts.get(i).getDescription()); } break; case 2: { hm.put("contactEmail", contacts.get(i).getDescription()); } break; case 3: { hm.put("contactSite", contacts.get(i).getDescription()); } break; } } addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm); } if (widget.hasParameter("send_sms")) { HashMap<String, String> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { sb.append(contacts.get(i).getDescription()); if (i < contacts.size() - 1) { sb.append(", "); } } hm.put("text", sb.toString()); addNativeFeature(NATIVE_FEATURES.SMS, null, hm); } if (widget.hasParameter("send_mail")) { HashMap<String, CharSequence> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { sb.append("Name: "); } break; case 1: { sb.append("Phone: "); } break; case 2: { sb.append("Email: "); } break; case 3: { sb.append("Site: "); } break; case 4: { sb.append("Address: "); } break; } sb.append(contacts.get(i).getDescription()); sb.append("<br/>"); } if (widget.isHaveAdvertisement()) { sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)"); } hm.put("text", sb.toString()); hm.put("subject", "Contacts"); addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm); } } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); } }
From source file:com.deliciousdroid.fragment.ViewBookmarkFragment.java
@Override public void onResume() { super.onResume(); readView.setBackgroundColor(Integer.parseInt(base.readingBackground)); readTitle.setBackgroundColor(Integer.parseInt(base.readingBackground)); if (Integer.parseInt(base.readingBackground) == Color.BLACK) { readView.setTextColor(Color.parseColor("#999999")); readTitle.setTextColor(Color.parseColor("#999999")); } else {/*from w w w. j av a 2 s . co m*/ readView.setTextColor(Color.parseColor("#222222")); readTitle.setTextColor(Color.parseColor("#222222")); } readView.setPadding(Integer.parseInt(base.readingMargins), 15, Integer.parseInt(base.readingMargins), 15); Typeface tf = Typeface.createFromAsset(base.getAssets(), "fonts/" + base.readingFont + ".ttf"); readView.setTypeface(tf); readView.setTextSize(Float.parseFloat(base.readingFontSize)); readView.setLineSpacing(Float.parseFloat(base.readingLineSpace), 1); }
From source file:com.ofalvai.bpinfo.api.bkkfutar.FutarApiClient.java
@NonNull private Route parseRoute(@NonNull JSONObject routeNode) throws JSONException { String id = routeNode.getString(RouteContract.ROUTE_ID); String shortName = routeNode.getString(RouteContract.ROUTE_SHORT_NAME); String longName;//www. ja va2s . co m try { longName = routeNode.getString(RouteContract.ROUTE_LONG_NAME); } catch (JSONException ex) { longName = null; } // Sometimes the description field is missing form the object String description; try { description = routeNode.getString(RouteContract.ROUTE_DESC); } catch (JSONException ex) { description = null; } RouteType type = parseRouteType(routeNode.getString(RouteContract.ROUTE_TYPE)); int color = Color.parseColor("#" + routeNode.getString(RouteContract.ROUTE_COLOR)); int textColor = Color.parseColor("#" + routeNode.getString(RouteContract.ROUTE_TEXT_COLOR)); return new Route(id, shortName, longName, description, type, color, textColor); }
From source file:com.example.jesse.barscan.BarcodeCaptureActivity.java
/** * onTap returns the tapped barcode result to the calling Activity. *//* www .j a va 2 s. c o m*/ public boolean onTap(float rawX, float rawY) { // Find tap point in preview frame coordinates. int[] location = new int[2]; mGraphicOverlay.getLocationOnScreen(location); float x = (rawX - location[0]) / mGraphicOverlay.getWidthScaleFactor(); float y = (rawY - location[1]) / mGraphicOverlay.getHeightScaleFactor(); // Find the barcode whose center is closest to the tapped point. Barcode best = null; float bestDistance = Float.MAX_VALUE; for (BarcodeGraphic graphic : mGraphicOverlay.getGraphics()) { Barcode barcode = graphic.getBarcode(); if (barcode.getBoundingBox().contains((int) x, (int) y)) { // Exact hit, no need to keep looking. best = barcode; break; } float dx = x - barcode.getBoundingBox().centerX(); float dy = y - barcode.getBoundingBox().centerY(); float distance = (dx * dx) + (dy * dy); // actually squared distance if (distance < bestDistance) { best = barcode; bestDistance = distance; } } if (best != null) { Intent data = new Intent(); data.putExtra(BarcodeObject, best); setResult(CommonStatusCodes.SUCCESS, data); LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.barcode_toast, (ViewGroup) findViewById(R.id.custom_toast_container)); Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject); //Barcode.DriverLicense dlBarcode = barcode.driverLicense; Barcode.DriverLicense sample = barcode.driverLicense; TextView name = (TextView) layout.findViewById(R.id.name); TextView address = (TextView) layout.findViewById(R.id.address); TextView cityStateZip = (TextView) layout.findViewById(R.id.cityStateZip); TextView gender = (TextView) layout.findViewById(R.id.gender); TextView dob = (TextView) layout.findViewById(R.id.dob); TableLayout tbl = (TableLayout) layout.findViewById(R.id.tableLayout); try { int age = DateDifference.generateAge(sample.birthDate); if (age < minAge) tbl.setBackgroundColor(Color.parseColor("#980517")); else tbl.setBackgroundColor(Color.parseColor("#617C17")); } catch (ParseException e) { e.printStackTrace(); } String cityContent = new String( sample.addressCity + ", " + sample.addressState + " " + (sample.addressZip).substring(0, 5)); address.setText(sample.addressStreet); cityStateZip.setText(cityContent); String genderString; if ((sample.gender).equals("1")) genderString = "Male"; else if ((sample.gender).equals("2")) genderString = "Female"; else genderString = "Other"; gender.setText(genderString); dob.setText((sample.birthDate).substring(0, 2) + "/" + (sample.birthDate).substring(2, 4) + "/" + (sample.birthDate).substring(4, 8)); String nameString = new String(sample.firstName + " " + sample.middleName + " " + sample.lastName); name.setText(nameString); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); Date today = Calendar.getInstance().getTime(); String reportDate = df.format(today); SQLiteDatabase db = helper.getWritableDatabase(); ContentValues row = new ContentValues(); row.put("dateVar", reportDate); row.put("dobVar", sample.birthDate); row.put("zipVar", sample.addressZip); row.put("genderVar", genderString); db.insert("test", null, row); db.close(); return true; } return false; }
From source file:com.eng.arab.translator.androidtranslator.activity.NumberViewActivity.java
private void setupFloatingSearch() { mSearchView.setOnHomeActionClickListener(new FloatingSearchView.OnHomeActionClickListener() { @Override//from w w w . j a v a 2 s . c o m public void onHomeClicked() { } }); mSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override public void onSearchTextChanged(String oldQuery, final String newQuery) { if (!oldQuery.equals("") && newQuery.equals("")) { mSearchView.clearSuggestions(); } else { //this shows the top left circular progress //you can call it where ever you want, but //it makes sense to do it when loading something in //the background. mSearchView.showProgress(); //simulates a query call to a data source //with a new query. NumberDataHelper.findSuggestions(getApplicationContext(), newQuery, 5, FIND_SUGGESTION_SIMULATED_DELAY, new NumberDataHelper.OnFindSuggestionsListener() { @Override public void onResults(List<NumberSuggestion> results) { //this will swap the data and //render the collapse/expand animations as necessary mSearchView.swapSuggestions(results); //let the users know that the background //process has completed mSearchView.hideProgress(); } }); } Log.d(TAG, "onSearchTextChanged()"); } }); mSearchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { @Override public void onSuggestionClicked(final SearchSuggestion searchSuggestion) { NumberSuggestion numberSuggestion = (NumberSuggestion) searchSuggestion; NumberDataHelper.findNumbers(getApplicationContext(), numberSuggestion.getWord(), new NumberDataHelper.OnFindNumberListener() { @Override public void onResults(List<NumberWrapper> results) { mSearchResultsAdapter.swapData(results); } }); Log.d(TAG, "onSuggestionClicked()"); mLastQuery = searchSuggestion.getWord(); } @Override public void onSearchAction(String query) { mLastQuery = query; NumberDataHelper.findNumbers(getApplicationContext(), query, new NumberDataHelper.OnFindNumberListener() { @Override public void onResults(List<NumberWrapper> results) { mSearchResultsAdapter.swapData(results); } }); Log.d(TAG, "onSearchAction()"); } }); mSearchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() { @Override public void onFocus() { //show suggestions when search bar gains focus (typically history suggestions) // NumberDataHelper cdh = new NumberDataHelper(); // cdh.setContext(getApplicationContext()); mSearchView.swapSuggestions(NumberDataHelper.getHistory(getApplicationContext(), 5)); Log.d(TAG, "onFocus()"); } @Override public void onFocusCleared() { //set the title of the bar so that when focus is returned a new query begins mSearchView.setSearchBarTitle(mLastQuery); //you can also set setSearchText(...) to make keep the query there when not focused and when focus returns //mSearchView.setSearchText(searchSuggestion.getWord()); Log.d(TAG, "onFocusCleared()"); } }); //handle menu clicks the same way as you would //in a regular activity mSearchView.setOnMenuItemClickListener(new FloatingSearchView.OnMenuItemClickListener() { @Override public void onActionMenuItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_refresh_list) { /*mIsDarkSearchTheme = true; //demonstrate setting colors for items mSearchView.setBackgroundColor(Color.parseColor("#787878")); mSearchView.setViewTextColor(Color.parseColor("#e9e9e9")); mSearchView.setHintTextColor(Color.parseColor("#e9e9e9")); mSearchView.setActionMenuOverflowColor(Color.parseColor("#e9e9e9")); mSearchView.setMenuItemIconColor(Color.parseColor("#e9e9e9")); mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9")); mSearchView.setClearBtnColor(Color.parseColor("#e9e9e9")); mSearchView.setDividerColor(Color.parseColor("#BEBEBE")); mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));*/ populateCardList(); } else if (item.getItemId() == R.id.action_voice_rec) { Intent voiceRecognize = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); voiceRecognize.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName()); voiceRecognize.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); voiceRecognize.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "ar-EG"); voiceRecognize.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say the letter in ARABIC..."); /*voiceRecognize.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true); */ voiceRecognize.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100); startActivityForResult(voiceRecognize, REQUEST_CODE); } else { //just print action //Toast.makeText(getApplicationContext().getApplicationContext(), item.getTitle(), // Toast.LENGTH_SHORT).show(); } } }); //use this listener to listen to menu clicks when app:floatingSearch_leftAction="showHome" mSearchView.setOnHomeActionClickListener(new FloatingSearchView.OnHomeActionClickListener() { @Override public void onHomeClicked() { startActivity(new Intent(NumberViewActivity.this, MainActivity.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left); Log.d(TAG, "onHomeClicked()"); } }); /* * Here you have access to the left icon and the text of a given suggestion * item after as it is bound to the suggestion list. You can utilize this * callback to change some properties of the left icon and the text. For example, you * can load the left icon images using your favorite image loading library, or change text color. * * * Important: * Keep in mind that the suggestion list is a RecyclerView, so views are reused for different * items in the list. */ mSearchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() { @Override public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) { NumberSuggestion numberSuggestion = (NumberSuggestion) item; String textColor = mIsDarkSearchTheme ? "#ffffff" : "#000000"; String textLight = mIsDarkSearchTheme ? "#bfbfbf" : "#787878"; if (numberSuggestion.getIsHistory()) { leftIcon.setImageDrawable( ResourcesCompat.getDrawable(getResources(), R.drawable.ic_history_black_24dp, null)); Util.setIconColor(leftIcon, Color.parseColor(textColor)); leftIcon.setAlpha(.36f); } else { leftIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_lightbulb_outline_black_24dp, null)); Util.setIconColor(leftIcon, Color.parseColor(textColor)); leftIcon.setAlpha(.36f); /*leftIcon.setAlpha(0.0f); leftIcon.setImageDrawable(null);*/ } textView.setTextColor(Color.parseColor(textColor)); String text = numberSuggestion.getWord().replaceFirst(mSearchView.getQuery(), "<font color=\"" + textLight + "\">" + mSearchView.getQuery() + "</font>"); textView.setText(Html.fromHtml(text)); } }); //listen for when suggestion list expands/shrinks in order to move down/up the //search results list mSearchView.setOnSuggestionsListHeightChanged(new FloatingSearchView.OnSuggestionsListHeightChanged() { @Override public void onSuggestionsListHeightChanged(float newHeight) { mSearchResultsList.setTranslationY(newHeight); } }); }