List of usage examples for android.widget TextView setTextColor
@android.view.RemotableViewMethod public void setTextColor(ColorStateList colors)
From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothFixTabView.java
/** * ??tab./*from w ww. ja va2 s . c om*/ * * @param tabText the tab text * @param fragment the fragment */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } //? ESLogUtil.d(ESSlidingSmoothFixTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.android.example.leanback.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)}./*from w w w. ja v a2 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.setTextColor(getResources().getColor(android.R.color.white)); 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.bitants.wally.fragments.MaterialDialogFragment.java
protected void setupViews(Context context) { if (titleResourceId != 0) { textViewTitle.setText(titleResourceId); } else if (titleString != null) { textViewTitle.setText(titleString); }/*from w w w . ja va2 s .c o m*/ if (primaryColor != 0) { buttonPositive.setTextColor(primaryColor); } if (positiveButtonTextResourceId != 0) { buttonPositive.setText(positiveButtonTextResourceId); } if (negativeButtonTextResourceId != 0) { buttonNegative.setText(negativeButtonTextResourceId); } buttonNegative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (negativeButtonOnClickListener != null) { negativeButtonOnClickListener.onClick(null, 1); } dismiss(); } }); buttonPositive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (positiveButtonOnClickListener != null) { positiveButtonOnClickListener.onClick(null, 0); } dismiss(); } }); if (layoutResourceId != 0) { viewStub.setLayoutResource(layoutResourceId); viewStub.inflate(); } else if (message != null || messageResourceId != 0) { TextView textView = new TextView(context); if (messageResourceId != 0) { textView.setText(messageResourceId); } else { textView.setText(message); } textView.setTextColor(getResources().getColor(R.color.Black_Light)); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); textView.setLineSpacing(1f, 1.2f); scrollView.removeAllViews(); scrollView.addView(textView); } }
From source file:key.secretkey.SettingsActivity.java
/** * Opens a file explorer to import the private key */// ww w .j a va 2 s. c om // public void getSshKey() { // // This always works // Intent i = new Intent(getApplicationContext(), FilePickerActivity.class); // // This works if you defined the intent filter // // Intent i = new Intent(Intent.ACTION_GET_CONTENT); // // // Set these depending on your use case. These are the defaults. // i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false); // i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false); // i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE); // // i.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath()); // // startActivityForResult(i, IMPORT_SSH_KEY); // } public void exportPasswordsWithPermissions() { final Activity activity = this; if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { Snackbar snack = Snackbar .make(prefsFragment.getView(), "We need access to the sd-card to export the passwords", Snackbar.LENGTH_INDEFINITE) .setAction(R.string.dialog_ok, new View.OnClickListener() { @Override public void onClick(View view) { ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_EXTERNAL_STORAGE); } }); snack.show(); View view = snack.getView(); TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); tv.setTextColor(Color.WHITE); tv.setMaxLines(10); } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_EXTERNAL_STORAGE); } } else { Intent i = new Intent(getApplicationContext(), FilePickerActivity.class); // Set these depending on your use case. These are the defaults. i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false); i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true); i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR); i.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath()); startActivityForResult(i, EXPORT_PASSWORDS); } }
From source file:com.app.viewslider.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)}./*from ww w . j a v a 2s . c o m*/ */ @SuppressLint("NewApi") 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.setTextColor(context.getResources().getColor(android.R.color.white)); 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.carver.paul.truesight.Ui.widget.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)}./*from w w w. j ava 2s . c om*/ */ 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.setTextColor(Color.WHITE); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.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:app.jorge.mobile.com.transportalert.ScrollingActivity.java
@Override public void onFailure(Throwable t) { Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); // handle execution failures like no internet connectivity LinearLayout item = (LinearLayout) findViewById(R.id.rv); Snackbar snackbar = Snackbar.make(item, "No internet connection!", Snackbar.LENGTH_INDEFINITE) .setAction("RETRY", new View.OnClickListener() { @Override/*from w w w. j av a 2 s . com*/ public void onClick(View view) { finish(); startActivity(getIntent()); } }); // Changing message text color snackbar.setActionTextColor(Color.RED); // Changing action button text color View sbView = snackbar.getView(); TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text); textView.setTextColor(Color.YELLOW); snackbar.show(); }
From source file:angeloid.dreamnarae.SwipeyTabs.java
@Override protected void dispatchDraw(Canvas canvas) { if (mCurrentPos != -1) { // calculate the relative position of the fronted tab to set the // alpha channel of the tab indicator final int tabSelectedTop = getHeight() - getPaddingBottom() - mBottomBarHeight - mTabIndicatorHeight; final View currentTab = getChildAt(mCurrentPos); final int centerOfTab = (mCurrentTabPos[mCurrentPos] + currentTab.getMeasuredWidth()) - (currentTab.getMeasuredWidth() / 2); final int center = getWidth() / 2; final int centerDiv3 = center / 3; final float relativePos = 1.0f - Math.min(Math.abs((float) (centerOfTab - center) / (float) (centerDiv3)), 1.0f); mCachedTabPaint.setAlpha((int) (255 * relativePos)); canvas.drawRect(mCurrentTabPos[mCurrentPos], tabSelectedTop, mCurrentTabPos[mCurrentPos] + currentTab.getMeasuredWidth(), tabSelectedTop + mTabIndicatorHeight, mCachedTabPaint); // set the correct text colors on the text views final int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { final TextView tab = (TextView) getChildAt(i); if (mCurrentPos == i) { tab.setTextColor(interpolateColor(mBottomBarColor, mTextColor, 1.0f - relativePos)); } else { tab.setTextColor(mTextColor); }// w ww . j a va 2s. c o m } } super.dispatchDraw(canvas); }
From source file:com.chess.genesis.view.SwipeTabs.java
@Override protected void dispatchDraw(final Canvas canvas) { if (mCurrentPos != -1) { // calculate the relative position of the fronted tab to set the // alpha channel of the tab indicator final int tabSelectedTop = getHeight() - getPaddingBottom() - mBottomBarHeight - mTabIndicatorHeight; final View currentTab = getChildAt(mCurrentPos); final int centerOfTab = (mCurrentTabPos[mCurrentPos] + currentTab.getMeasuredWidth()) - (currentTab.getMeasuredWidth() / 2); final int center = getWidth() / 2; final int centerDiv3 = center / 3; final float relativePos = 1.0f - Math.min(Math.abs((float) (centerOfTab - center) / (float) (centerDiv3)), 1.0f); mCachedTabPaint.setAlpha((int) (255 * relativePos)); canvas.drawRect(mCurrentTabPos[mCurrentPos], tabSelectedTop, mCurrentTabPos[mCurrentPos] + currentTab.getMeasuredWidth(), tabSelectedTop + mTabIndicatorHeight, mCachedTabPaint); // set the correct text colors on the text views final int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { final TextView tab = (TextView) getChildAt(i); if (mCurrentPos == i) tab.setTextColor(interpolateColor(mBottomBarColor, mTextColor, 1.0f - relativePos)); else//from ww w .j a v a2s.com tab.setTextColor(mTextColor); } } super.dispatchDraw(canvas); }
From source file:ch.timjahn.learningapp.ls.java
public void control(View view) { int progress = ((SeekBar) findViewById(R.id.seekBar)).getProgress(); TextView tv = (TextView) findViewById(R.id.solution); tv.setVisibility(View.VISIBLE); switch (activeQ) { case 1:/*from w w w. ja v a 2 s. co m*/ if (activeA.equals(answer1)) { tv.setText("Richtig (~90|100)."); tv.setTextColor(Color.parseColor("#00CC00")); } else { tv.setText("Falsch."); tv.setTextColor(Color.RED); } break; case 2: if (activeA.equals(answer2)) { tv.setText("Richtig (~45|100)"); tv.setTextColor(Color.parseColor("#00CC00")); } else { tv.setText("Falsch."); tv.setTextColor(Color.RED); } break; } }