本文整理汇总了Java中android.widget.TextView.BufferType类的典型用法代码示例。如果您正苦于以下问题:Java BufferType类的具体用法?Java BufferType怎么用?Java BufferType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BufferType类属于android.widget.TextView包,在下文中一共展示了BufferType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDescriptionLine
import android.widget.TextView.BufferType; //导入依赖的package包/类
/**
* Sets a description line for the omnibox suggestion.
*
* @param str The description text.
* @param isUrl Whether this text is a URL (as opposed to a normal string).
*/
private void showDescriptionLine(Spannable str, boolean isUrl) {
TextView textLine = mContentsView.mTextLine2;
if (textLine.getVisibility() != VISIBLE) {
textLine.setVisibility(VISIBLE);
}
textLine.setText(str, BufferType.SPANNABLE);
// Force left-to-right rendering for URLs. See UrlBar constructor for details.
if (isUrl) {
textLine.setTextColor(URL_COLOR);
ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR);
} else {
textLine.setTextColor(getStandardFontColor());
ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT);
}
}
示例2: setTextHilighted
import android.widget.TextView.BufferType; //导入依赖的package包/类
public static void setTextHilighted(TextView textView, String text,SearchElement searchElement) {
textView.setText(text);
if (textView == null
|| TextUtils.isEmpty(text)
|| searchElement ==null) {
return;
}
int startIndex = searchElement.startIndex;
int endIndex = searchElement.endIndex;
if (startIndex < 0 || endIndex > text.length()) {
return;
}
// 开始高亮处理
int color = Color.rgb(69, 192, 26);
textView.setText(text, BufferType.SPANNABLE);
Spannable span = (Spannable) textView.getText();
span.setSpan(new ForegroundColorSpan(color), startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
示例3: setStatus
import android.widget.TextView.BufferType; //导入依赖的package包/类
public static void setStatus(final TextView textView, final String text) {
final String htmlText = text + " ";
// LogUtil.v(TAG, "setStatus:htmlText:" + htmlText);
final HashMap<String, String> mentions = findMentions(htmlText);
// LogUtil.v(TAG, "setStatus:mentions:" + mentions);
final String plainText = Html.fromHtml(htmlText).toString();
// LogUtil.v(TAG, "setStatus:plainText:" + plainText);
final SpannableString spannable = new SpannableString(plainText);
Linkify.addLinks(spannable, Linkify.WEB_URLS);
linkifyUsers(spannable, mentions);
linkifyTags(spannable);
removeUnderLines(spannable);
// LogUtil.v(TAG, "setStatus:finalText:" + spannable);
textView.setText(spannable, BufferType.SPANNABLE);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
示例4: setItemStatus
import android.widget.TextView.BufferType; //导入依赖的package包/类
public static void setItemStatus(final TextView textView, final String text) {
final String htmlText = text + " ";
final List<String> highlightWords = findHighlightWords(htmlText);
final String plainText = Html.fromHtml(htmlText).toString();
final SpannableString spannable = new SpannableString(plainText);
Linkify.addLinks(spannable, Linkify.WEB_URLS);
final Matcher m = PATTERN_USER.matcher(spannable);
while (m.find()) {
int start = m.start(1);
int end = m.end(1);
if (start >= 0 && start < end) {
spannable.setSpan(new ForegroundColorSpan(AppContext.getContext().getResources().getColor(R.color.colorPrimary)), start, end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
linkifyTags(spannable);
removeUnderLines(spannable);
applyHighlightSpan(spannable, highlightWords);
textView.setText(spannable, BufferType.SPANNABLE);
}
示例5: applyLetterSpacing
import android.widget.TextView.BufferType; //导入依赖的package包/类
/**
* 字距为任何字符串(技术上,一个简单的方法为CharSequence不使用)的TextView
*/
private void applyLetterSpacing() {
if (this == null || this.originalText == null) return;
StringBuilder builder = new StringBuilder();
for(int i = 0; i < originalText.length(); i++) {
String c = ""+ originalText.charAt(i);
builder.append(c.toLowerCase());
if(i+1 < originalText.length()) {
builder.append("\u00A0");
}
}
SpannableString finalText = new SpannableString(builder.toString());
if(builder.toString().length() > 1) {
for(int i = 1; i < builder.toString().length(); i+=2) {
finalText.setSpan(new ScaleXSpan((letterSpacing+1)/10), i, i+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
super.setText(finalText, BufferType.SPANNABLE);
}
示例6: fontAndReshape
import android.widget.TextView.BufferType; //导入依赖的package包/类
public static void fontAndReshape(TextView tv) {
String text = "";
if (tv.getText() instanceof SpannedString) {
text = ((SpannedString) tv.getText()).toString();
} else if (tv.getText() instanceof SpannableString) {
text = ((SpannableString) tv.getText()).toString();
} else {
text = (String) tv.getText();
}
if (tv instanceof StyledTextView)
((StyledTextView) tv).setPlainText(text, BufferType.NORMAL);
else if (tv instanceof StyledButton)
((StyledButton) tv).setPlainText(text, BufferType.NORMAL);
else if (tv instanceof StyledEditText)
((StyledEditText) tv).setPlainText(text, BufferType.NORMAL);
tv.setTypeface(getFont("Yekan"));
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
}
示例7: getView
import android.widget.TextView.BufferType; //导入依赖的package包/类
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
ViewHolder holder;
if (row == null) {
row = inflater.inflate(R.layout.search_results_row, null);
holder = new ViewHolder();
holder.bookName = (TextView)row.findViewById(R.id.search_result_row_book);
holder.chapterNumber = (TextView)row.findViewById(R.id.search_result_row_chapter);
holder.verseNumber = (TextView)row.findViewById(R.id.search_result_row_verse_number);
holder.verseText = (TextView)row.findViewById(R.id.search_result_row_verse_text);
row.setTag(holder);
}
else
holder = (ViewHolder)row.getTag();
final Verse entry = (Verse)super.getItem(position);
//Log.d(TAG, "Verse: " + entry.number + " - " + entry.text);
holder.bookName.setText(bookNameLookupMap.get(entry.bookId));
holder.chapterNumber.setText("Chapter " + entry.chapter);
holder.verseNumber.setText("[" + entry.number + "]");
holder.verseText.setText(highlightSearchString(entry.text), BufferType.SPANNABLE);
return row;
}
示例8: makeDialog
import android.widget.TextView.BufferType; //导入依赖的package包/类
private static Dialog makeDialog(Context context, int title, Spanned message)
{
TextView textView = new TextView(context);
textView.setText(message, BufferType.SPANNABLE );
textView.setMovementMethod( LinkMovementMethod.getInstance() );
ScrollView scrollView = new ScrollView(context);
scrollView.addView( textView );
final Dialog dialog = new AlertDialog.Builder(context).
setTitle( title ).
setView( scrollView ).
setNeutralButton( "OK", null ).
setCancelable(true).
setIcon( android.R.drawable.ic_dialog_info).
create();
return dialog;
}
示例9: onServiceConnected
import android.widget.TextView.BufferType; //导入依赖的package包/类
public void onServiceConnected(ComponentName className, IBinder service) {
bService = service;
mService = new Messenger(service);
try {
Message msg = Message.obtain(null, MedtronicConstants.MSG_REGISTER_CLIENT);
msg.replyTo = mMessenger;
mService.send(msg);
} catch (RemoteException e) {
StringBuffer sb1 = new StringBuffer("");
sb1.append("EXCEPTION!!!!!! "+ e.getMessage()+" "+e.getCause());
for (StackTraceElement st : e.getStackTrace()){
sb1.append(st.toString()).append("\n");
}
Log.e(TAG,"Error Registering Client Service Connection\n"+sb1.toString());
if (ISDEBUG){
display.setText(display.getText()+"Error Registering Client Service Connection\n", BufferType.EDITABLE);
}
// In this case the service has crashed before we could even do anything with it
}
}
示例10: initViews
import android.widget.TextView.BufferType; //导入依赖的package包/类
private void initViews() {
SpannableString spannable = new SpannableString(getString(R.string.app_name));
spannable.setSpan(new ForegroundColorSpan(Color.rgb(99, 194, 208)), 0, 4, 0);
spannable.setSpan(new ForegroundColorSpan(Color.rgb(255, 255, 255)), 5, 7, 1);
spannable.setSpan(new ForegroundColorSpan(Color.rgb(255, 212, 0)), 7,spannable.length(), 2);
final TextView appTitle = (TextView) findViewById(R.id.login_app_tittle);
appTitle.setText(spannable, BufferType.SPANNABLE);
btnLoginFacebook = (ImageButton) findViewById(R.id.loginFbBtn);
btnLogin = (ImageButton) findViewById(R.id.loginBtn);
btnGuest = (ImageButton) findViewById(R.id.loginGuestBtn);
btnRegister = (Button) findViewById(R.id.register);
mTwitterBtn = (ImageButton) findViewById(R.id.loginTwBtn);
etUsername = (EditText) findViewById(R.id.etLoginUser);
etPassowrd = (EditText)findViewById(R.id.etLoginPassword);
btnLogin.setOnClickListener(this);
btnLoginFacebook.setOnClickListener(this);
btnRegister.setOnClickListener(this);
btnGuest.setOnClickListener(this);
mTwitterBtn.setOnClickListener(this);
}
示例11: addOrRemoveAppView
import android.widget.TextView.BufferType; //导入依赖的package包/类
void addOrRemoveAppView(final ISearchableElement searchableElement, final Match match) {
final View appView = searchableElement.getViewDetails().getSearchResultView();
final boolean matches = match.isMatches();
ViewDetails viewDetails = searchableElement.getViewDetails();
final TextView primaryTextDisplay = viewDetails.getPrimaryTextDisplay();
runOnUiThread(new Runnable(){
@Override
public void run() {
if(matches){
if(appView.getParent() == null){
searchResultsView.addView(appView);
searchResultsCount++;
}
} else {
if(appView.getParent() == searchResultsView){
searchResultsView.removeView(appView);
searchResultsCount--;
}
}
searchCountText.setText(String.valueOf(searchResultsCount));
primaryTextDisplay.setText(match.getMatchedSpan(),BufferType.SPANNABLE);
}
});
}
示例12: priceFee
import android.widget.TextView.BufferType; //导入依赖的package包/类
@Override
public void priceFee(String totalCostStr) {
// mFreight_money.setText("RMB:"+totalCostStr);
SpannableString styledText = new SpannableString("RMB"+totalCostStr);
styledText.setSpan(new AbsoluteSizeSpan(15,true), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
styledText.setSpan(new AbsoluteSizeSpan(20,true), 3, ("RMB"+totalCostStr).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mFreight_money.setText(styledText, BufferType.SPANNABLE);
}
示例13: onSetUpView
import android.widget.TextView.BufferType; //导入依赖的package包/类
@Override
public void onSetUpView() {
EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
// 设置内容
contentView.setText(span, BufferType.SPANNABLE);
handleTextMessage();
}
示例14: setLikeUsers
import android.widget.TextView.BufferType; //导入依赖的package包/类
public void setLikeUsers(Context contet, TextView likeUser, boolean limit) {
// 构造多个超链接的html, 通过选中的位置来获取用户名
if (getLikeCount() > 0 && getLikeUser() != null
&& !getLikeUser().isEmpty()) {
likeUser.setVisibility(View.VISIBLE);
likeUser.setMovementMethod(LinkMovementMethod.getInstance());
likeUser.setFocusable(false);
likeUser.setLongClickable(false);
likeUser.setText(addClickablePart(contet, limit), BufferType.SPANNABLE);
} else {
likeUser.setVisibility(View.GONE);
likeUser.setText("");
}
likeUser.setVisibility(View.GONE);
}
示例15: setText
import android.widget.TextView.BufferType; //导入依赖的package包/类
public void setText(CharSequence text, BufferType type) {
try {
if (!TextUtils.isEmpty(text)) {
SpannableStringBuilder builder = new SpannableStringBuilder(text);
EmojiconHandler.addEmojis(getContext(), builder, this.mEmojiconSize, this
.mTextStart, this.mTextLength, this.mUseSystemDefault);
text = builder;
}
super.setText(text, type);
} catch (IndexOutOfBoundsException e) {
setText(text.toString());
}
}