private void c() { TextView localTextView = (TextView)findViewById(2131624178); RelativeSizeSpan localRelativeSizeSpan = new RelativeSizeSpan(0.55F); SpannableString localSpannableString = new SpannableString(getContext().getString(2131296739, new Object[] { h.c() })); localSpannableString.setSpan(localRelativeSizeSpan, localSpannableString.toString().indexOf('\n') + 1, localSpannableString.length(), 0); localTextView.setText(localSpannableString); }
/** * 设置标题 @Title: setTitle * * @param actionBar * @param spannableString */ @TargetApi(11) public static void setTitle(ActionBar actionBar, SpannableString spannableString) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN && Build.MANUFACTURER.toUpperCase().equals("LGE")) { actionBar.setTitle(spannableString.toString()); } else { actionBar.setTitle(spannableString); } }
public static void setColorSpan(SpannableString str, String spanStr, int color) { try { String ori = str.toString(); int f = ori.indexOf(spanStr); int l = f + spanStr.length(); str.setSpan(new ForegroundColorSpan(color), f, l, 0); } catch (Exception e) { // e.printStackTrace(); } }
public static void setUnderlineSpan(SpannableString str, String spanStr) { try { String ori = str.toString(); int f = ori.indexOf(spanStr); int l = f + spanStr.length(); str.setSpan(new UnderlineSpan(), f, l, 0); } catch (Exception e) { // e.printStackTrace(); } }
/** 自定义infowinfow窗口, 设置title 和 snippet 的内容 */ public void render(Marker marker, View view) { if (!marker.getId().equals(marker_id)) return; String title = marker.getTitle(); TextView titleUi = ((TextView) view.findViewById(R.id.main_infowindow_textview_title_id)); if (title != null) { SpannableString titleText = new SpannableString(title); titleUi.setText(titleText); Log.e("title", titleText.toString()); } else { titleUi.setText(""); } if (marker.getId().equals(marker_id)) { String snippet = marker.getSnippet(); TextView snippetUi = ((TextView) view.findViewById(R.id.main_infowindow_textview_snippet_id)); if (snippet != null) { SpannableString snippetText = new SpannableString(snippet); snippetUi.setText(snippetText); Log.e("snippet", snippetText.toString()); } else { titleUi.setText(""); } } }
private boolean showNextPermissionGroupGrantRequest() { final int groupCount = mRequestGrantPermissionGroups.size(); int currentIndex = 0; for (GroupState groupState : mRequestGrantPermissionGroups.values()) { if (groupState.mState == GroupState.STATE_UNKNOWN) { CharSequence appLabel = mAppPermissions.getAppLabel(); SpannableString message = new SpannableString( getString( R.string.permission_warning_template, appLabel, groupState.mGroup.getDescription())); // Set the permission message as the title so it can be announced. setTitle(message); // Color the app name. int appLabelStart = message.toString().indexOf(appLabel.toString(), 0); int appLabelLength = appLabel.length(); int color = getColor(R.color.grant_permissions_app_color); message.setSpan( new ForegroundColorSpan(color), appLabelStart, appLabelStart + appLabelLength, 0); // Set the new grant view // TODO: Use a real message for the action. We need group action APIs Resources resources; try { resources = getPackageManager().getResourcesForApplication(groupState.mGroup.getIconPkg()); } catch (NameNotFoundException e) { // Fallback to system. resources = Resources.getSystem(); } int icon = groupState.mGroup.getIconResId(); mViewHandler.updateUi( groupState.mGroup.getName(), groupCount, currentIndex, Icon.createWithResource(resources, icon), message, groupState.mGroup.isUserSet()); return true; } currentIndex++; } return false; }