List of usage examples for android.widget TextView setTextAppearance
@Deprecated public void setTextAppearance(Context context, @StyleRes int resId)
From source file:com.homework.group.videoplayer.ui.widgets.slidingTab.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* ww w . j ava 2s. c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextAppearance(context, R.style.SlidingTextViewStyle); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); // textView.setBackgroundResource(R.color.theme_color); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:la.mejorando.prelollipopmaterialdesign.views.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//w ww .j a va2 s . c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextAppearance(context, R.style.SlidingTextViewStyle); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java
/** * <b>Call always after dialog.show!!!!!!!!!</b> * //from www.ja va2s. c o m * @param alertDialog */ public void dialogStyle(AlertDialog alertDialog) { TextView textView = (TextView) alertDialog.findViewById(android.R.id.message); if (textView != null) { textView.setBackgroundDrawable(null); textView.setTextAppearance(this, R.style.muspydialogmessage); } Button button = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); if (button != null) { button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector)); } button = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); if (button != null) { button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector)); } button = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); if (button != null) { button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector)); } }
From source file:com.mine.psf.PsfFileBrowserActivity.java
@Override protected Dialog onCreateDialog(int id) { // show dialog according to the id final String msg; if (id == ID_ABOUT) { // Get version code String versionString = ""; PackageManager manager = getPackageManager(); try {/*from w w w . ja v a2 s .co m*/ PackageInfo info = manager.getPackageInfo(getPackageName(), 0); versionString = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } // Format dialog msg msg = String.format(getString(R.string.sexypsf_about), versionString); } else { Log.e(LOGTAG, "Unknown dialog id"); msg = ""; } final TextView msgView = new TextView(this); msgView.setText(msg); msgView.setAutoLinkMask(Linkify.ALL); msgView.setTextAppearance(this, android.R.style.TextAppearance_Medium); msgView.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(this).setView(msgView).setCancelable(true) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked OK so do some stuff */ } }).create(); }
From source file:com.svpino.longhorn.activities.DashboardActivity.java
private void displayTermsAndConditions() { SharedPreferences sharedPreferences = getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE); boolean wereTermsAndConditionsAlreadyAccepted = sharedPreferences .getBoolean(Constants.PREFERENCE_TERMS_AND_CONDITIONS, false); if (!wereTermsAndConditionsAlreadyAccepted) { AlertDialog.Builder termsAndConditionsDialogBuilder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.dialog_message, null); TextView textView = (TextView) view.findViewById(R.id.textView); textView.setText(String.format(getString(R.string.terms_and_conditions_message), getString(R.string.application_name))); textView.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Small); termsAndConditionsDialogBuilder.setTitle(R.string.terms_and_conditions_title).setView(view) .setCancelable(false)// www. j a v a 2 s. c om .setPositiveButton(R.string.label_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences sharedPreferences = getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE); Editor editor = sharedPreferences.edit(); editor.putBoolean(Constants.PREFERENCE_TERMS_AND_CONDITIONS, true); editor.commit(); DashboardActivity.this.termsAndConditionsDialog.dismiss(); } }).setNegativeButton(R.string.label_disagree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); this.termsAndConditionsDialog = termsAndConditionsDialogBuilder.create(); this.termsAndConditionsDialog.show(); } }
From source file:com.infigent.stocksense.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startService(new Intent(this, BackGround.class)); // setSlidingActionBarEnabled(true); Intent n = getIntent();//from ww w . j a v a 2 s. c o m if (getIntent() != null) { Bundle bundle = n.getExtras(); if (bundle != null) { Log.e("ARG", "EXIST"); if (bundle.containsKey("eq")) { Log.e("EQ", "EXIST"); if (bundle.getBoolean("eq")) { Log.e("eq", "true"); Bundle data = new Bundle(); Fragment4 eq = new Fragment4(); mContent = eq; data.putString("q", bundle.getString("q")); data.putString("type", bundle.getString("type")); data.putString("name", bundle.getString("name")); data.putString("f", gId()); eq.setArguments(data); switchContent(eq); } } } } if (savedInstanceState != null) mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); if (mContent == null) mContent = new Fragment1(); ScrollView scrollView = new ScrollView(this); LinearLayout l = new LinearLayout(this); TextView one = new TextView(this); one.setText(getResources().getString(R.string.intro)); one.setPadding(0, 0, 0, 20); TextView two = new TextView(this); two.setText("Limited License"); two.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView three = new TextView(this); three.setText(getResources().getString(R.string.l1)); TextView four = new TextView(this); four.setText(getResources().getString(R.string.l2)); four.setPadding(0, 0, 0, 20); TextView five = new TextView(this); five.setText("Disclaimer"); five.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView six = new TextView(this); six.setText(getResources().getString(R.string.disclaimer1)); TextView seven = new TextView(this); seven.setText(getResources().getString(R.string.disclaimer2)); TextView eight = new TextView(this); eight.setText(getResources().getString(R.string.disclaimer3)); eight.setPadding(0, 0, 0, 20); TextView nine = new TextView(this); nine.setText("Liability For Our Services"); nine.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView ten = new TextView(this); ten.setText(getResources().getString(R.string.liability1)); TextView eleven = new TextView(this); eleven.setText(getResources().getString(R.string.liability2)); eleven.setPadding(0, 0, 0, 20); TextView twelve = new TextView(this); twelve.setText("Maintenance And Support"); twelve.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView thirteen = new TextView(this); thirteen.setText(getResources().getString(R.string.ms)); thirteen.setPadding(0, 0, 0, 20); TextView fourteen = new TextView(this); fourteen.setText("Links To Third Party Website"); fourteen.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium); TextView fifteen = new TextView(this); fifteen.setText(getResources().getString(R.string.p3)); l.addView(one); l.addView(two); l.addView(three); l.addView(four); l.addView(five); l.addView(six); l.addView(seven); l.addView(eight); l.addView(nine); l.addView(ten); l.addView(eleven); l.addView(twelve); l.addView(thirteen); l.addView(fourteen); l.addView(fifteen); one.setTextColor(getResources().getColor(R.color.White)); two.setTextColor(getResources().getColor(R.color.White)); three.setTextColor(getResources().getColor(R.color.White)); four.setTextColor(getResources().getColor(R.color.White)); five.setTextColor(getResources().getColor(R.color.White)); six.setTextColor(getResources().getColor(R.color.White)); seven.setTextColor(getResources().getColor(R.color.White)); eight.setTextColor(getResources().getColor(R.color.White)); nine.setTextColor(getResources().getColor(R.color.White)); ten.setTextColor(getResources().getColor(R.color.White)); eleven.setTextColor(getResources().getColor(R.color.White)); twelve.setTextColor(getResources().getColor(R.color.White)); thirteen.setTextColor(getResources().getColor(R.color.White)); fourteen.setTextColor(getResources().getColor(R.color.White)); fifteen.setTextColor(getResources().getColor(R.color.White)); l.setOrientation(LinearLayout.VERTICAL); l.setBackgroundColor(getResources().getColor(R.color.bg)); l.setPadding(10, 10, 10, 10); scrollView.addView(l); boolean firstboot = getSharedPreferences("BOOT_PREF", MODE_PRIVATE).getBoolean("firstboot", true); if (firstboot) { LayoutInflater inflater = getLayoutInflater(); View vvv = inflater.inflate(R.layout.alerttitle, null); AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("Terms of Service") .setView(scrollView).setCustomTitle(vvv) .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); getSharedPreferences("BOOT_PREF", MODE_PRIVATE).edit().putBoolean("firstboot", false) .commit(); } }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Close the activity as they have declined the EULA MainActivity.this.finish(); } }).setCancelable(false); builder.create().show(); } ime = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); ActionBar actionBar = getSupportActionBar(); getSupportActionBar().setCustomView(R.layout.search); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); sb = (ImageButton) actionBar.getCustomView().findViewById(R.id.sb); title = (TextView) actionBar.getCustomView().findViewById(R.id.title); sb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // only will trigger it if no physical keyboard is open search.setVisibility(View.VISIBLE); search.requestFocus(); ime.showSoftInput(search, InputMethodManager.SHOW_IMPLICIT); search.setSelection(search.getText().length()); sb.setVisibility(View.GONE); title.setVisibility(View.GONE); } }); search = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.et); search.setThreshold(2); search.setAdapter(new SuggestionsAdapter(this, search.getText().toString())); search.setSelectAllOnFocus(true); search.clearFocus(); search.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) { String term = parent.getItemAtPosition(pos).toString(); String[] lines = term.split("\\r?\\n"); String name = lines[0]; String code = lines[1].substring(lines[1].indexOf(":") + 1, lines[1].length()).trim(); String type = lines[1].substring(0, lines[1].indexOf(":")); Log.d("DATA", name + " " + type + ":" + code); search.setText(""); if (isNetworkAvailable()) { if (term.replace(" ", "") != null) { Bundle data = new Bundle(); data.putString("q", code); data.putString("type", type); data.putString("name", name); data.putString("f", gId()); Fragment4 eq = new Fragment4(); eq.setArguments(data); Log.d("C", gId() + " frag"); mContent = eq; getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, eq).commit(); getSlidingMenu().showContent(); search.setVisibility(View.GONE); sb.setVisibility(View.VISIBLE); title.setVisibility(View.VISIBLE); ime.hideSoftInputFromWindow(search.getApplicationWindowToken(), 0); } else { Toast.makeText(getApplicationContext(), "Enter a search term!", Toast.LENGTH_LONG).show(); } } else Toast.makeText(getApplicationContext(), "Internet not available", Toast.LENGTH_LONG).show(); } }); search.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { return false; } }); // set the Above View setContentView(R.layout.content_frame); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); AdView mAdView; mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); // set the Behind View setBehindContentView(R.layout.menu_frame); getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new SampleListFragment()).commit(); }
From source file:com.xda.one.ui.widget.TabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set * via//from ww w .ja va 2 s. c om * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); // Modified for XDA One final TypedValue typedValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.textAppearanceSmallInverse, typedValue, true); textView.setTextAppearance(getContext(), typedValue.resourceId); getContext().getTheme().resolveAttribute(android.R.attr.textColorPrimaryInverse, typedValue, true); textView.setTextColor(getResources().getColor(typedValue.resourceId)); textView.setTypeface(null, Typeface.BOLD); // Customized for app textView.setLayoutParams( new LinearLayout.LayoutParams(0, MATCH_PARENT, 1f / mViewPager.getAdapter().getCount())); textView.setSingleLine(); AutofitHelper.create(textView); // Modified for XDA One getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true); textView.setBackgroundResource(typedValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private TextView makeTextView(String value, int color, int horizontalPadding) { Context context = getActivity(); TextView textView = new TextView(context); textView.setText(value);/*from w ww .j a v a 2s. c om*/ textView.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); textView.setTextAppearance(context, android.R.attr.textAppearanceSmall); textView.setTextColor(color); textView.setPadding(horizontalPadding, 0, horizontalPadding, 0); textView.setSingleLine(false); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { textView.setTextIsSelectable(true); } return textView; }
From source file:org.dvbviewer.controller.ui.base.BaseListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * /*from ww w . j a v a 2s . c om*/ * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. * * @param inflater the inflater * @param container the container * @param savedInstanceState the saved instance state * @return the view * @author RayBa * @date 07.04.2013 */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); if (layoutRessource > 0) { View v = getLayoutInflater(savedInstanceState).inflate(layoutRessource, null); return v; } else { FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyle); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; } }
From source file:com.grokkingandroid.sampleapp.samples.SampleBaseFragment.java
@SuppressLint("NewApi") protected void showLinks(ViewGroup container) { String[] linkTexts = getLinkTexts(); String[] linkTargets = getLinkTargets(); StringBuilder link = null;/* w ww . ja va2 s . c om*/ for (int i = 0; i < linkTexts.length; i++) { // TODO: Use an inflater TextView tv = new TextView(getActivity()); LinearLayout.LayoutParams params = null; params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); if (i != linkTexts.length - 1) { int marginBottom = getResources().getDimensionPixelSize(R.dimen.linkSpacing); params.setMargins(0, 0, 0, marginBottom); } tv.setLayoutParams(params); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { tv.setTextIsSelectable(true); } tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium); link = new StringBuilder(100); link.append("<a href=\""); link.append(linkTargets[i]); link.append("\">"); link.append(linkTexts[i]); link.append("</a>"); Spanned spannedLink = Html.fromHtml(link.toString()); tv.setText(spannedLink); tv.setMovementMethod(LinkMovementMethod.getInstance()); container.addView(tv); } }