List of usage examples for android.widget TextView setTextColor
@android.view.RemotableViewMethod public void setTextColor(ColorStateList colors)
From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java
private void createTableLayoutTrainAvailability() { if (mPage.contains("SORRY")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Not a valid class, Please select a different class and try again."); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews();//from www . j a v a2 s . com mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ISL Of")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ERROR")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("Network Connectivity")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("unavailable")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText( "Response from server:\n\nYour request could not be processed now.\nPlease try again later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) { Iterator iterator = null; try { iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("TrainDetails", mPage); e.printStackTrace(); return; } mListAv = new ArrayList<List<String>>(); List<String> list; Element tmp; tmp = (Element) iterator.next(); list = new ArrayList<String>(); list.add(tmp.select("th").get(0).text()); list.add("Date"); list.add(tmp.select("th").get(2).text()); //list.add(tmp.select("th").get(3).text()); mListAv.add(list); while (iterator.hasNext()) { tmp = (Element) iterator.next(); if (!tmp.hasText()) { continue; } list = new ArrayList<String>(); list.add(tmp.select("td").get(0).text()); list.add(tmp.select("td").get(1).text()); list.add(tmp.select("td").get(2).text()); //list.add(tmp.select("td").get(3).text()); mListAv.add(list); } mDetails = new Details(mListAv, TrainEnquiry.AVAILABILITY, mTrainNumber); } else { mListAv = mDetails.getList(); } mTblLayoutAv = new TableLayout(mActivity); TableRow row; TextView tv1, tv2, tv3; mTblLayoutAv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < mListAv.size(); i++) { row = new TableRow(mActivity); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv3 = new TextView(mActivity); //tv4 = new TextView(mActivity); tv1.setText(" " + mListAv.get(i).get(0)); tv2.setText(" " + mListAv.get(i).get(1)); tv3.setText(" " + mListAv.get(i).get(2)); //tv4.setText(" " + mListAv.get(i).get(3)); tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv3.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); //tv4.setTextAppearance(mActivity,android.R.style.TextAppearance_DeviceDefault_Medium); tv1.setPadding(5, 5, 5, 5); tv2.setPadding(5, 5, 5, 5); tv3.setPadding(5, 5, 5, 5); //tv4.setPadding(5,5,5,5); /*tv2.setBackgroundResource(R.drawable.card_divider); tv3.setBackgroundResource(R.drawable.card_divider); tv4.setBackgroundResource(R.drawable.card_divider);*/ row.addView(tv1); row.addView(tv2); row.addView(tv3); //row.addView(tv4); row.setBackgroundResource(R.drawable.button_selector); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); row.setOnClickListener(this); mTblLayoutAv.addView(row); } LinearLayout ll = new LinearLayout(mActivity); ScrollView scrollView = new ScrollView(mActivity); TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Availability details:"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(textViewTrnDtls); ll.addView(mTblLayoutAv); scrollView.addView(ll); mFrameLayout.removeAllViews(); mFrameLayout.addView(scrollView); if (mDialog.isShowing()) { mDialog.cancel(); } }
From source file:com.example.drugsformarinemammals.Dose_Information.java
public void show_dose(ArrayList<Dose_Data> dose, TableLayout dose_table, TableRow dose_data, String drug_name, String group_name, String animal_family, String animal_name, String animal_category, ArrayList<String> notes, ArrayList<String> references, ArrayList<Article_Reference> references_index) { String doseAmount;/*from w w w . ja va2 s . co m*/ String dosePosology; String doseRoute; String doseBookReference; String doseArticleReference; for (int k = 0; k < dose.size(); k++) { if (k > 0) { dose_data = new TableRow(this); } doseAmount = dose.get(k).getAmount(); dosePosology = dose.get(k).getPosology(); doseRoute = dose.get(k).getRoute(); doseBookReference = dose.get(k).getBookReference(); doseArticleReference = dose.get(k).getArticleReference(); //Dose amount data TextView textView_animal_dose_amount = new TextView(this); textView_animal_dose_amount.setText(doseAmount); textView_animal_dose_amount.setSingleLine(false); textView_animal_dose_amount.setTextColor(Color.BLACK); textView_animal_dose_amount.setTextSize(15); textView_animal_dose_amount.setTypeface(Typeface.SANS_SERIF); TableRow.LayoutParams paramsDoseAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseAmount.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_amount, paramsDoseAmount); //Dose posology data TextView textView_animal_dose_posology = new TextView(this); textView_animal_dose_posology.setText(dosePosology); textView_animal_dose_posology.setSingleLine(false); textView_animal_dose_posology.setTextColor(Color.BLACK); textView_animal_dose_posology.setTextSize(15); textView_animal_dose_posology.setTypeface(Typeface.SANS_SERIF); TableRow.LayoutParams paramsDosePosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDosePosology.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Posology")) || screenWidth >= 600) dose_data.addView(textView_animal_dose_posology, paramsDosePosology); //Dose route data TextView textView_animal_dose_route = new TextView(this); textView_animal_dose_route.setText(doseRoute); textView_animal_dose_route.setSingleLine(false); textView_animal_dose_route.setTextColor(Color.BLACK); textView_animal_dose_route.setTextSize(15); textView_animal_dose_route.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600) { TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseRoute.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_route, paramsDoseRoute); } else { TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(30, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseRoute.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_route, paramsDoseRoute); } //Dose reference data TextView textView_animal_dose_reference = new TextView(this); if (!doseBookReference.equals("")) textView_animal_dose_reference.setText(doseBookReference); else if (!doseArticleReference.equals("")) { if (!references.contains(doseArticleReference)) { references.add(references.size(), doseArticleReference); Article_Reference article_reference = new Article_Reference(reference_index, doseArticleReference); references_index.add(references_index.size(), article_reference); reference_index++; } int article_index = references.indexOf(doseArticleReference); textView_animal_dose_reference.setText("(" + references_index.get(article_index).getIndex() + ")"); } textView_animal_dose_reference.setSingleLine(false); textView_animal_dose_reference.setTextColor(Color.BLACK); textView_animal_dose_reference.setTextSize(15); textView_animal_dose_reference.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600) { TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseReference.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_reference, paramsDoseReference); } else { TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(150, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseReference.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_reference, paramsDoseReference); } //Specific note index ArrayList<String> specific_notes = new ArrayList<String>(); specific_notes = helper.read_specific_notes(drug_name, group_name, animal_name, animal_family, animal_category, doseAmount, dosePosology, doseRoute, doseBookReference, doseArticleReference); String index = ""; for (int m = 0; m < specific_notes.size(); m++) { String note = specific_notes.get(m); if (!notes.contains(note)) { notes.add(notes.size(), note); } index += "(" + (notes.indexOf(note) + 1) + ") "; } TextView textView_specific_note_index = new TextView(this); textView_specific_note_index.setText(index); textView_specific_note_index.setSingleLine(false); textView_specific_note_index.setTextColor(Color.BLACK); textView_specific_note_index.setTextSize(15); textView_specific_note_index.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600 && screenWidth < 720) { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(150, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } else if (screenWidth >= 720) { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } else { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(100, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Note")) || screenWidth >= 600) dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } dose_table.addView(dose_data); } }
From source file:brostore.maquillage.custom.PagerSlidingTabStrip.java
private void setTextViewStyle(View v) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); // TODO//from w ww . ja v a2 s. co m //tab.setTextColor(tabTextColor); ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, //1 new int[] { android.R.attr.state_selected }, //2 new int[] {} //3 }, new int[] { Color.WHITE, //1 Color.WHITE, //2 getResources().getColor(R.color.tab_text_color_unselected) //3 }); tab.setTextColor(colorStateList); tab.setTextScaleX(tabTextScaleX); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } }
From source file:com.bhb27.isu.Checks.java
public void checkSafety() { cancheckSafety = false;/*from w w w . j a v a 2 s. c om*/ boolean adbRoot = Tools.AndroidDebugRoot() && Tools.AndroidDebugState(getActivity()), su = Tools.SuBinary(), selinux, system; ViewGroup base_parent = (ViewGroup) getActivity().findViewById(R.id.base_parent); View alertLayout = LayoutInflater.from(getActivity()).inflate(R.layout.safety_check_dialog, base_parent, false); final TextView SU_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_su); final TextView Selinux_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_Selinux); final TextView adb_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_adb); final TextView system_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_system); final TextView props_textView = (TextView) alertLayout.findViewById(R.id.checkDialog_props); if (isCMSU && rootAccess) { SU_textView.setText(getString(R.string.su_state) + ": " + (su ? getString(R.string.activated) : getString(R.string.deactivated))); if (su) SU_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); } if (rootAccess) { selinux = Tools.isSELinuxActive(getActivity()); Selinux_textView.setText(getString(R.string.selinux_state) + ": " + (selinux ? getString(R.string.enforcing) : getString(R.string.permissive))); if (!selinux) Selinux_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); } else { SU_textView.setText(getString(R.string.su_state) + ": " + getString(R.string.device_not_root)); selinux = Tools.isSELinuxActiveNoROOT(); Selinux_textView.setText(getString(R.string.selinux_state) + ": " + (selinux ? getString(R.string.enforcing) : getString(R.string.permissive))); if (!selinux) Selinux_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); } adb_textView.setText(getString(R.string.adb_state_root) + ": " + (adbRoot ? getString(R.string.running) : getString(R.string.not_running))); if (adbRoot) adb_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); if (rootAccess) { system = Tools.runCommand("cat /proc/mounts | grep system", su, getActivity()).contains("rw"); system_textView.setText(getString(R.string.system_mouted) + ": " + (system ? getString(R.string.system_mouted_rw) : getString(R.string.system_mouted_ro))); if (system) system_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); } else system_textView.setVisibility(View.GONE); String redprops = Tools.redProps(); props_textView.setText(getString(R.string.props) + ": " + (!redprops.isEmpty() ? redprops : getString(R.string.props_status_good))); if (!redprops.isEmpty()) props_textView.setTextColor(ContextCompat.getColor(getActivity(), R.color.colorAccent)); new AlertDialog.Builder(getActivity(), R.style.AlertDialogStyle).setTitle(getString(R.string.safety_net)) .setView(alertLayout).setPositiveButton(getString(R.string.dismiss), null).show(); Tools.logStatus(getActivity()); cancheckSafety = true; }
From source file:acc.healthapp.tabs.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* ww w . ja v a2 s. c om*/ TextView tabTitleView = null; ImageView tabImageView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(getResources().getColor(R.color.white)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.achenging.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*w w w . j av a 2s. c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); if (i == mViewPager.getCurrentItem()) { tabTitleView.setTextColor(mTabSelectedTextColor); } else { tabTitleView.setTextColor(mTabTextColor); } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); mTabStrip.addView(tabView, params); } }
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void displayArtistInfo(JSONObject j) throws JSONException { if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config);//from w w w.ja v a 2s .c om Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString()); //JSONObject j_artist_info = j.getJSONObject("artist"); final String artist_name = j.getString("name"); tArtistName.setText(artist_name); final JSONObject urls = j.optJSONObject("urls"); final JSONArray videos = j.optJSONArray("video"); final JSONArray images = j.optJSONArray("images"); final String msg = artist_name.replaceAll("\\p{Punct}", " ").replaceAll("\\p{Space}", "+"); AsyncHttpClient client = new AsyncHttpClient(); String fmURL = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + msg + "&autocorrect[1]&format=json&api_key=ca4c10f9ae187ebb889b33ba12da7ee9"; Log.i("musicInfo", fmURL); client.get(fmURL, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { String r = new String(responseBody); ArrayList<String> image_urls = new ArrayList<String>(); try { Log.i("musicInfo", "Communicating with LastFM..."); JSONObject json = new JSONObject(r); Log.i("musicInfo", json.toString()); json = json.getJSONObject("artist"); Log.i("musicInfo", json.toString()); JSONArray artist_images = json.optJSONArray("image"); Log.i("musicInfo", artist_images.toString()); for (int i = 0; i < artist_images.length(); i++) { JSONObject j = artist_images.getJSONObject(i); Log.i("musicInfo", j.optString("size")); if (j.optString("size").contains("extralarge")) { image_urls.add(j.optString("#text")); //b.putString("fm_image", j.getString("#text")); //Log.i("musicInfo", j.getString("#text")); break; } } } catch (JSONException e) { e.printStackTrace(); } if (images != null) { for (int i = 0; i < images.length(); i++) { JSONObject image = null; try { image = images.getJSONObject(i); } catch (JSONException e) { e.printStackTrace(); } int width = image.optInt("width", 0); int height = image.optInt("height", 0); String url = image.optString("url", ""); Log.i("musicInfo", i + ": " + url); if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) { //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) { image_urls.add(url); Log.i("musicInfo", "Selected: " + url); //available_images.put(image); } } } int random = (int) (Math.random() * image_urls.size()); final String f_url = image_urls.get(random); Log.i("musicInfo", "Total image#=" + image_urls.size() + " Selected image#=" + random + " " + f_url); if (image_urls.size() > 0) { imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { lLinkList.removeAllViews(); //String attr = fImage.optJSONObject("license").optString("attribution"); //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr)); if (urls != null) { String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url", "twitter_url" }; for (int i = 0; i < jsonName.length; i++) { if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) { Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i])); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); switch (jsonName[i]) { case "official_url": tv.setText("HOME."); break; case "wikipedia_url": tv.setText("WIKI."); break; case "mb_url": tv.setText("Music Brainz."); break; case "lastfm_url": tv.setText("Last FM."); break; case "twitter_url": tv.setText("Twitter."); break; } try { tv.setTag(urls.getString(jsonName[i])); } catch (JSONException e) { e.printStackTrace(); } tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) v.getTag())); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Toast.makeText(getApplicationContext(), "Open the Link...", Toast.LENGTH_SHORT).show(); //finish(); } }); lLinkList.addView(tv); } } } else { TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText("Sorry, No Link Here..."); lLinkList.addView(tv); } if (videos != null) { jVideoArray = videos; mAdapter = new StaggeredViewAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, generateImageData(videos)); //if (mData == null) { mData = generateImageData(videos); //} //mAdapter.clear(); for (JSONObject data : mData) { mAdapter.add(data); } mGridView.setAdapter(mAdapter); } else { } adjBottomColor(((ImageView) view).getDrawable()); } @Override public void onLoadingCancelled(String imageUri, View view) { } }); } else { ArtistImage.setImageResource(R.drawable.lamb_no_image_available); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { } }); }
From source file:com.arlib.floatingsearchviewdemo.MainActivity.java
private void setupFloatingSearch() { mSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override/* ww w .j a v a 2 s . co m*/ 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. DataHelper.findSuggestions(MainActivity.this, newQuery, 5, FIND_SUGGESTION_SIMULATED_DELAY, new DataHelper.OnFindSuggestionsListener() { @Override public void onResults(List<ColorSuggestion> 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(SearchSuggestion searchSuggestion) { ColorSuggestion colorSuggestion = (ColorSuggestion) searchSuggestion; DataHelper.findColors(MainActivity.this, colorSuggestion.getBody(), new DataHelper.OnFindColorsListener() { @Override public void onResults(List<ColorWrapper> results) { mSearchResultsAdapter.swapData(results); } }); Log.d(TAG, "onSuggestionClicked()"); } @Override public void onSearchAction(String query) { DataHelper.findColors(MainActivity.this, query, new DataHelper.OnFindColorsListener() { @Override public void onResults(List<ColorWrapper> results) { mSearchResultsAdapter.swapData(results); } }); Log.d(TAG, "onSearchAction()"); } }); mSearchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() { @Override public void onFocus() { mSearchView.clearQuery(); //show suggestions when search bar gains focus (typically history suggestions) mSearchView.swapSuggestions(DataHelper.getHistory(MainActivity.this, 3)); Log.d(TAG, "onFocus()"); } @Override public void onFocusCleared() { 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_change_colors) { 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")); } else { //just print action Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show(); } } }); //use this listener to listen to menu clicks when app:floatingSearch_leftAction="showHamburger" mSearchView.setOnLeftMenuClickListener(new FloatingSearchView.OnLeftMenuClickListener() { @Override public void onMenuOpened() { Log.d(TAG, "onMenuOpened()"); mDrawerLayout.openDrawer(GravityCompat.START); } @Override public void onMenuClosed() { Log.d(TAG, "onMenuClosed()"); } }); //use this listener to listen to menu clicks when app:floatingSearch_leftAction="showHome" mSearchView.setOnHomeActionClickListener(new FloatingSearchView.OnHomeActionClickListener() { @Override public void onHomeClicked() { 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) { ColorSuggestion colorSuggestion = (ColorSuggestion) item; String textColor = mIsDarkSearchTheme ? "#ffffff" : "#000000"; String textLight = mIsDarkSearchTheme ? "#bfbfbf" : "#787878"; if (colorSuggestion.getIsHistory()) { leftIcon.setImageDrawable( ResourcesCompat.getDrawable(getResources(), R.drawable.ic_history_black_24dp, null)); Util.setIconColor(leftIcon, Color.parseColor(textColor)); leftIcon.setAlpha(.36f); } else { leftIcon.setAlpha(0.0f); leftIcon.setImageDrawable(null); } textView.setTextColor(Color.parseColor(textColor)); String text = colorSuggestion.getBody().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); } }); }
From source file:com.anjoola.sharewear.util.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from ww w . ja va 2 s .co m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.alvinhkh.ftpsync.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from ww w .j av a2 s. c om*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); if (selectorTextColor != null) { tabTitleView.setTextColor(selectorTextColor); } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }