List of usage examples for android.graphics Typeface BOLD
int BOLD
To view the source code for android.graphics Typeface BOLD.
Click Source Link
From source file:larry.baby.rain.common.view.TabPageIndicator.java
private void addTab(CharSequence text, int index) { Context context = getContext(); DisplayMetrics dm = context.getResources().getDisplayMetrics(); int padX = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 22, dm); int padY = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, dm); TextView tabView = new TextView(context); tabView.setBackgroundResource(R.drawable.vpi__tab_indicator); tabView.setPadding(padX, padY, padX, padY); tabView.setGravity(Gravity.CENTER);/*from ww w . ja v a 2 s . c om*/ tabView.setTextColor(0xfff3f3f3); tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); tabView.setTypeface(tabView.getTypeface(), Typeface.BOLD); tabView.setSingleLine(); tabView.setTag(index); tabView.setFocusable(true); tabView.setOnClickListener(this); tabView.setText(text); mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); }
From source file:com.money.manager.ex.reports.IncomeVsExpensesAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView txtYear = (TextView) view.findViewById(R.id.textViewYear); TextView txtMonth = (TextView) view.findViewById(R.id.textViewMonth); TextView txtIncome = (TextView) view.findViewById(R.id.textViewIncome); TextView txtExpenses = (TextView) view.findViewById(R.id.textViewExpenses); TextView txtDifference = (TextView) view.findViewById(R.id.textViewDifference); // take data/*from w ww .j a v a 2 s . com*/ int year, month; year = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.YEAR)); month = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Month)); Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, 1); double income = 0, expenses = 0; expenses = cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Expenses)); income = cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Income)); // attach data txtYear.setText(Integer.toString(year)); String formatMonth = context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? "MMM" : "MMMM"; if (month != IncomeVsExpensesActivity.SUBTOTAL_MONTH) { txtMonth.setText(new SimpleDateFormat(formatMonth).format(calendar.getTime())); } else { txtMonth.setText(null); } CurrencyService currencyService = new CurrencyService(mContext); txtIncome.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income))); txtExpenses.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(Math.abs(expenses)))); txtDifference.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income - Math.abs(expenses)))); UIHelper uiHelper = new UIHelper(context); if (income - Math.abs(expenses) < 0) { txtDifference.setTextColor( context.getResources().getColor(uiHelper.resolveAttribute(R.attr.holo_red_color_theme))); } else { txtDifference.setTextColor( context.getResources().getColor(uiHelper.resolveAttribute(R.attr.holo_green_color_theme))); } //view.setBackgroundColor(core.resolveColorAttribute(cursor.getPosition() % 2 == 1 ? R.attr.row_dark_theme : R.attr.row_light_theme)); // check if subtotal int typefaceStyle = month == IncomeVsExpensesActivity.SUBTOTAL_MONTH ? Typeface.BOLD : Typeface.NORMAL; txtDifference.setTypeface(null, typefaceStyle); txtExpenses.setTypeface(null, typefaceStyle); txtIncome.setTypeface(null, typefaceStyle); txtMonth.setTypeface(null, typefaceStyle); txtYear.setTypeface(null, typefaceStyle); }
From source file:de.ktran.anno1404warenrechner.views.PopulationNumberDialog.java
private void setAdvancementText(int value, PopulationType.Civilization civilization) { String advanceTextStart = getActivity().getString(R.string.advance_to); String advanceName = getPopulationTypeByProgress(value, civilization).getString(getContext()); if (advancementText != null) { advancementText.setText(advanceTextStart + " " + advanceName.toLowerCase(), TextView.BufferType.SPANNABLE); Spannable sp = (Spannable) advancementText.getText(); sp.setSpan(new StyleSpan(Typeface.BOLD), advanceTextStart.length(), 1 + advanceTextStart.length() + advanceName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }/*from w w w .jav a 2 s . c o m*/ }
From source file:org.akvo.caddisfly.sensor.colorimetry.strip.instructions.InstructionDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_instruction_detail, container, false); Drawable instructionDrawable = AssetsManager.getImage(getActivity(), getArguments().getString(ARG_ITEM_IMAGE)); if (instructionDrawable != null) { ((ImageView) rootView.findViewById(R.id.image_illustration)).setImageDrawable(instructionDrawable); }/*ww w.j a v a 2s.c o m*/ ArrayList<String> instructionText = getArguments().getStringArrayList(ARG_ITEM_TEXT); if (instructionText != null) { LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.layout_instructions); for (String instruction : instructionText) { TextView textView = new TextView(getActivity()); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.mediumTextSize)); textView.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.activity_vertical_margin)); textView.setLineSpacing(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5.0f, getResources().getDisplayMetrics()), 1.0f); String text = instruction; if (instruction.contains("<!>")) { text = instruction.replaceAll("<!>", ""); textView.setTextColor(Color.RED); } else { textView.setTextColor(Color.DKGRAY); } if (instruction.contains("<b>")) { text = text.replaceAll("<b>", "").replaceAll("</b>", ""); textView.setTypeface(null, Typeface.BOLD); } else { textView.setTextColor(Color.DKGRAY); } Spanned spanned = StringUtil.getStringResourceByName(getContext(), text); if (!text.isEmpty()) { textView.append(spanned); linearLayout.addView(textView); } } } return rootView; }
From source file:com.dmbstream.android.adapter.ConcertListAdapter.java
@Override public View getView(final int position, View convertView, final ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.partial_concert_list_item, parent, false); }//from w ww .j a v a 2 s . c o m Concert concert = getItem(position); TextView date = (TextView) convertView.findViewById(R.id.ConcertItemDate); TextView artist = (TextView) convertView.findViewById(R.id.ConcertItemArtist); TextView name = (TextView) convertView.findViewById(R.id.ConcertItemName); if (concert != null) { Date d = new Date(concert.date.getTimeInMillis()); DateFormat shortDateFormat = new SimpleDateFormat("yyyy-MM-dd"); date.setText(shortDateFormat.format(d)); artist.setText(concert.artistAbbreviation); name.setText(concert.name); // Need to (re)set this because the views are reused. If we don't // then // while scrolling, some items will replace the old // "Load more concerts" // view and will be in italics name.setTypeface(name.getTypeface(), Typeface.BOLD); date.setVisibility(View.VISIBLE); artist.setVisibility(View.VISIBLE); } else { // null marker means it's the end of the list. name.setTypeface(name.getTypeface(), Typeface.ITALIC); name.setText(R.string.msg_load_more_concerts); date.setVisibility(View.GONE); artist.setVisibility(View.GONE); } return convertView; }
From source file:org.sirimangalo.meditationplus.AdapterChat.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;//from ww w . ja v a 2s. c o m if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.list_item_chat, parent, false); } else { rowView = convertView; } JSONObject p = values.get(position); try { int then = Integer.parseInt(p.getString("time")); long nowL = System.currentTimeMillis() / 1000; int now = (int) nowL; int ela = now - then; int day = 60 * 60 * 24; ela = ela > day ? day : ela; int intColor = 255 - Math.round((float) ela * 255 / day); intColor = intColor > 100 ? intColor : 100; String hexTransparency = Integer.toHexString(intColor); hexTransparency = hexTransparency.length() > 1 ? hexTransparency : "0" + hexTransparency; String hexColor = "#" + hexTransparency + "000000"; int transparency = Color.parseColor(hexColor); TextView time = (TextView) rowView.findViewById(R.id.time); if (time != null) { String ts = null; ts = Utils.time2Ago(then); time.setText(ts); time.setTextColor(transparency); } TextView mess = (TextView) rowView.findViewById(R.id.message); if (mess != null) { final String username = p.getString("username"); String messageString = p.getString("message"); messageString = Html.fromHtml(messageString).toString(); SpannableString messageSpan = Utils.replaceSmilies(context, messageString, intColor); if (messageString.contains("@" + loggedUser)) { int index = messageString.indexOf("@" + loggedUser); messageSpan.setSpan(new StyleSpan(Typeface.BOLD), index, index + loggedUser.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); messageSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "990000")), index, index + loggedUser.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } for (String user : users) { if (!user.equals(loggedUser) && messageString.contains("@" + user)) { int index = messageString.indexOf("@" + user); messageSpan = Utils.createProfileSpan(context, index, index + user.length() + 1, user, messageSpan); messageSpan.setSpan( new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "009900")), index, index + user.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } Spannable userSpan = Utils.createProfileSpan(context, 0, username.length(), username, new SpannableString(username + ": ")); if (p.getString("me").equals("true")) userSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "0000FF")), 0, userSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); else userSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "000000")), 0, userSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); CharSequence full = TextUtils.concat(userSpan, messageSpan); mess.setTextColor(transparency); mess.setText(full); mess.setMovementMethod(LinkMovementMethod.getInstance()); Linkify.addLinks(mess, Linkify.ALL); mess.setTag(p.getString("cid")); } } catch (JSONException e) { e.printStackTrace(); } return rowView; }
From source file:org.videolan.vlc2.gui.SidebarAdapter.java
@Override public View getView(int position, View v, ViewGroup parent) { SidebarEntry sidebarEntry = entries.get(position); /* If view not created */ if (v == null) { v = mInflater.inflate(R.layout.sidebar_item, parent, false); }/*from w w w. j a va 2s .com*/ TextView textView = (TextView) v; textView.setText(sidebarEntry.name); Drawable img = VLCApplication.getAppResources() .getDrawable(Util.getResourceFromAttribute(mContext, sidebarEntry.attributeID)); if (img != null) { int dp_32 = Util.convertDpToPx(32); img.setBounds(0, 0, dp_32, dp_32); textView.setCompoundDrawables(img, null, null, null); } // Set in bold the current item. if (mCurrentFragmentId.equals(sidebarEntry.id)) textView.setTypeface(null, Typeface.BOLD); else textView.setTypeface(null, Typeface.NORMAL); return v; }
From source file:nz.al4.airclock.AirClockFragment.java
private View setupDate() { // add digital date textDate = new TextClock(getContext()); textDate.setId(textDateId);/*from w ww . j a v a 2 s . c o m*/ RelativeLayout.LayoutParams textDateParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textDateParams.addRule(RelativeLayout.BELOW, textClockId); textDate.setLayoutParams(textDateParams); textDate.setTypeface(textDate.getTypeface(), Typeface.BOLD); textDate.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textDate.setGravity(Gravity.CENTER_HORIZONTAL); SpannableString dateSpan = new SpannableString("yyyy/MM/dd"); textDate.setFormat24Hour(dateSpan); textDate.setFormat12Hour(dateSpan); return textDate; }
From source file:org.sufficientlysecure.keychain.ui.adapter.SubkeysAddedAdapter.java
public View getView(final int position, View convertView, ViewGroup parent) { if (convertView == null) { // Not recycled, inflate a new view convertView = mInflater.inflate(R.layout.view_key_adv_subkey_item, parent, false); final ViewHolder holder = new ViewHolder(); holder.vKeyId = (TextView) convertView.findViewById(R.id.subkey_item_key_id); holder.vKeyDetails = (TextView) convertView.findViewById(R.id.subkey_item_details); holder.vKeyExpiry = (TextView) convertView.findViewById(R.id.subkey_item_expiry); holder.vCertifyIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_certify); holder.vSignIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_sign); holder.vEncryptIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_encrypt); holder.vAuthenticateIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_authenticate); holder.vDelete = (ImageButton) convertView.findViewById(R.id.subkey_item_delete_button); holder.vDelete.setVisibility(View.VISIBLE); // always visible // not used: ImageView vEdit = (ImageView) convertView.findViewById(R.id.subkey_item_edit_image); vEdit.setVisibility(View.GONE); ImageView vStatus = (ImageView) convertView.findViewById(R.id.subkey_item_status); vStatus.setVisibility(View.GONE); convertView.setTag(holder);/*from w w w. j av a2s. c om*/ } final ViewHolder holder = (ViewHolder) convertView.getTag(); // save reference to model item holder.mModel = getItem(position); String algorithmStr = KeyFormattingUtils.getAlgorithmInfo(mActivity, holder.mModel.mAlgorithm, holder.mModel.mKeySize, holder.mModel.mCurve); boolean isMasterKey = mNewKeyring && position == 0; if (isMasterKey) { holder.vKeyId.setTypeface(null, Typeface.BOLD); holder.vDelete.setImageResource(R.drawable.ic_change_grey_24dp); holder.vDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // swapping out the old master key with newly set master key AddSubkeyDialogFragment addSubkeyDialogFragment = AddSubkeyDialogFragment.newInstance(true); addSubkeyDialogFragment.setOnAlgorithmSelectedListener( new AddSubkeyDialogFragment.OnAlgorithmSelectedListener() { @Override public void onAlgorithmSelected(SaveKeyringParcel.SubkeyAdd newSubkey) { // calculate manually as the provided position variable // is not always accurate int pos = SubkeysAddedAdapter.this.getPosition(holder.mModel); SubkeysAddedAdapter.this.remove(holder.mModel); SubkeysAddedAdapter.this.insert(newSubkey, pos); } }); addSubkeyDialogFragment.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "addSubkeyDialog"); } }); } else { holder.vKeyId.setTypeface(null, Typeface.NORMAL); holder.vDelete.setImageResource(R.drawable.ic_close_grey_24dp); holder.vDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // remove reference model item from adapter (data and notify about change) SubkeysAddedAdapter.this.remove(holder.mModel); } }); } holder.vKeyId.setText(R.string.edit_key_new_subkey); holder.vKeyDetails.setText(algorithmStr); if (holder.mModel.mExpiry != 0L) { Date expiryDate = new Date(holder.mModel.mExpiry * 1000); Calendar expiryCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiryCal.setTime(expiryDate); // convert from UTC to time zone of device expiryCal.setTimeZone(TimeZone.getDefault()); holder.vKeyExpiry.setText(getContext().getString(R.string.label_expiry) + ": " + DateFormat.getDateFormat(getContext()).format(expiryCal.getTime())); } else { holder.vKeyExpiry.setText( getContext().getString(R.string.label_expiry) + ": " + getContext().getString(R.string.none)); } int flags = holder.mModel.mFlags; if ((flags & KeyFlags.CERTIFY_OTHER) > 0) { holder.vCertifyIcon.setVisibility(View.VISIBLE); } else { holder.vCertifyIcon.setVisibility(View.GONE); } if ((flags & KeyFlags.SIGN_DATA) > 0) { holder.vSignIcon.setVisibility(View.VISIBLE); } else { holder.vSignIcon.setVisibility(View.GONE); } if (((flags & KeyFlags.ENCRYPT_COMMS) > 0) || ((flags & KeyFlags.ENCRYPT_STORAGE) > 0)) { holder.vEncryptIcon.setVisibility(View.VISIBLE); } else { holder.vEncryptIcon.setVisibility(View.GONE); } if ((flags & KeyFlags.AUTHENTICATION) > 0) { holder.vAuthenticateIcon.setVisibility(View.VISIBLE); } else { holder.vAuthenticateIcon.setVisibility(View.GONE); } return convertView; }
From source file:com.mikecorrigan.trainscorekeeper.FragmentSummary.java
@SuppressLint("NewApi") @Override/* w ww.j a v a 2 s .c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.vc(VERBOSE, TAG, "onCreateView: inflater=" + inflater + ", container=" + container + ", savedInstanceState=" + Utils.bundleToString(savedInstanceState)); View rootView = inflater.inflate(R.layout.fragment_summary, container, false); final MainActivity activity = (MainActivity) getActivity(); final Context context = activity; final Resources resources = context.getResources(); // Get the model and attach a listener. game = activity.getGame(); if (game != null) { game.addListener(mGameListener); } players = activity.getPlayers(); // Get resources. String[] playerNames = resources.getStringArray(R.array.playerNames); TypedArray drawablesArray = resources.obtainTypedArray(R.array.playerDrawables); TypedArray playerTextColorsArray = resources.obtainTypedArray(R.array.playerTextColors); int[] playerTextColorsIds = new int[playerTextColorsArray.length()]; for (int i = 0; i < playerTextColorsArray.length(); i++) { playerTextColorsIds[i] = playerTextColorsArray.getResourceId(i, -1); } // Get root view. ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.scroll_view); // Create table. tableLayout = new TableLayout(context); TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableLayout.setLayoutParams(tableLayoutParams); scrollView.addView(tableLayout); // Add header. { TableRow row = new TableRow(context); row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tableLayout.addView(row); TextView tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.player)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.trains)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.contracts)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.bonuses)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); } // Add rows. for (int i = 0; i < players.getNum(); i++) { TableRow row = new TableRow(context); row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tableLayout.addView(row); ToggleButton toggleButton = new ToggleButton(context); toggleButton.setGravity(Gravity.CENTER); toggleButton.setPadding(10, 10, 10, 10); toggleButton.setText(playerNames[i]); toggleButton.setClickable(false); Drawable drawable = drawablesArray.getDrawable(i); int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { toggleButton.setBackgroundDrawable(drawable); } else { toggleButton.setBackground(drawable); } toggleButton.setTextColor(resources.getColor(playerTextColorsIds[i])); row.addView(toggleButton); TextView tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); row.addView(tv); } Bundle args = getArguments(); if (args == null) { Log.e(TAG, "onCreateView: missing arguments"); return rootView; } drawablesArray.recycle(); playerTextColorsArray.recycle(); // final int index = args.getInt(ARG_INDEX); // final String tabSpec = args.getString(ARG_TAB_SPEC); return rootView; }