當前位置: 首頁>>代碼示例>>Java>>正文


Java TextAppearanceSpan類代碼示例

本文整理匯總了Java中android.text.style.TextAppearanceSpan的典型用法代碼示例。如果您正苦於以下問題:Java TextAppearanceSpan類的具體用法?Java TextAppearanceSpan怎麽用?Java TextAppearanceSpan使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TextAppearanceSpan類屬於android.text.style包,在下文中一共展示了TextAppearanceSpan類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: highlightTerm

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
private void highlightTerm(TextView tv, String query, String originalString){
    if (query != null && !query.isEmpty()) {
        int startPos = originalString.toLowerCase().indexOf(query.toLowerCase());
        int endPos = startPos + query.length();
        if (startPos != -1) {
            Spannable spannable = new SpannableString(originalString);
            ColorStateList blackColor = new ColorStateList(new int[][]{new int[]{}}, new int[]{Color.BLACK});
            TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, blackColor, null);
            spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            tv.setText(spannable);
        } else {
            tv.setText(originalString);
        }
    } else {
        tv.setText(originalString);
    }
}
 
開發者ID:broakenmedia,項目名稱:MultiContactPicker,代碼行數:18,代碼來源:MultiContactPickerAdapter.java

示例2: QuickConversationAdapter

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
public QuickConversationAdapter(final Context context, List<Message> messageList, EmojiconHandler emojiconHandler) {
    this.context = context;
    this.emojiconHandler = emojiconHandler;
    this.contactService = new AppContactService(context);
    this.messageDatabaseService = new MessageDatabaseService(context);
    this.messageList = messageList;
    contactImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) {
        @Override
        protected Bitmap processBitmap(Object data) {
            return contactService.downloadContactImage((Activity) context, (Contact) data);
        }
    };
    contactImageLoader.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f);
    contactImageLoader.setImageFadeIn(false);
    channelImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) context)) {
        @Override
        protected Bitmap processBitmap(Object data) {
            return contactService.downloadGroupImage((Activity) context, (Channel) data);
        }
    };
    channelImageLoader.addImageCache(((FragmentActivity) context).getSupportFragmentManager(), 0.1f);
    channelImageLoader.setImageFadeIn(false);
    final String alphabet = context.getString(R.string.alphabet);
    mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet);
    highlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHiglight);
}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:27,代碼來源:QuickConversationAdapter.java

示例3: ChannelAdapter

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
/**
 * Instantiates a new Contacts Adapter.
 *
 * @param context A context that has access to the app's layout.
 */
public ChannelAdapter(Context context) {
    super(context, null, 0);
    this.context = context;
    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight);
}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:21,代碼來源:ChannelFragment.java

示例4: ContactsAdapter

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
/**
 * Instantiates a new Contacts Adapter.
 *
 * @param context A context that has access to the app's layout.
 */
public ContactsAdapter(Context context) {
    super(context, null, 0);

    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);

    // Loads a string containing the English alphabet. To fully localize the app, provide a
    // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file,
    // define a string with android:name="alphabet" and contents set to all of the
    // alphabetic characters in the language in their proper sort order, in upper case if
    // applicable.
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, ContactsQuery.SORT_KEY, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight);
}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:27,代碼來源:ContactsListFragment.java

示例5: ContactsAdapter

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
/**
 * Instantiates a new Contacts Adapter.
 *
 * @param context A context that has access to the app's layout.
 */
public ContactsAdapter(Context context) {
    super(context, null, 0);
    this.context = context;
    userIdList = new ArrayList<String>();
    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);
    // Loads a string containing the English alphabet. To fully localize the app, provide a
    // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file,
    // define a string with android:name="alphabet" and contents set to all of the
    // alphabetic characters in the language in their proper sort order, in upper case if
    // applicable.
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(context, R.style.searchTextHiglight);
}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:27,代碼來源:ContactSelectionFragment.java

示例6: ContactsAdapter

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
/**
 * Instantiates a new Contacts Adapter.
 *
 * @param context A context that has access to the app's layout.
 */
public ContactsAdapter(Context context) {
    super(context, null, 0);
    this.context = context;
    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);
    // Loads a string containing the English alphabet. To fully localize the app, provide a
    // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file,
    // define a string with android:name="alphabet" and contents set to all of the
    // alphabetic characters in the language in their proper sort order, in upper case if
    // applicable.
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight);
}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:26,代碼來源:AppContactFragment.java

示例7: setTitleAndImage

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
private void setTitleAndImage(RecordingCardView cardView, ScheduledRecording recording) {
    Channel channel = mChannelDataManager.getChannel(recording.getChannelId());
    SpannableString title = recording.getProgramTitleWithEpisodeNumber(mContext) == null ?
            null : new SpannableString(recording.getProgramTitleWithEpisodeNumber(mContext));
    if (TextUtils.isEmpty(title)) {
        title = new SpannableString(channel != null ? channel.getDisplayName()
                : mContext.getResources().getString(R.string.no_program_information));
    } else {
        String programTitle = recording.getProgramTitle();
        title.setSpan(new TextAppearanceSpan(mContext,
                R.style.text_appearance_card_view_episode_number),
                programTitle == null ? 0 : programTitle.length(), title.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    String imageUri = recording.getProgramPosterArtUri();
    boolean isChannelLogo = false;
    if (TextUtils.isEmpty(imageUri)) {
        imageUri = channel != null ?
                TvContract.buildChannelLogoUri(channel.getId()).toString() : null;
        isChannelLogo = true;
    }
    cardView.setTitle(title);
    cardView.setImageUri(imageUri, isChannelLogo);
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:25,代碼來源:ScheduledRecordingPresenter.java

示例8: getTitleFromProgram

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
/**
 * Returns program title with episode number. If the program is null, returns channel name.
 */
protected CharSequence getTitleFromProgram(BaseProgram program, Channel channel) {
    String titleWithEpisodeNumber = program.getTitleWithEpisodeNumber(getContext());
    SpannableString title = titleWithEpisodeNumber == null ? null
            : new SpannableString(titleWithEpisodeNumber);
    if (TextUtils.isEmpty(title)) {
        title = new SpannableString(channel != null ? channel.getDisplayName()
                : getContext().getResources().getString(
                R.string.no_program_information));
    } else {
        String programTitle = program.getTitle();
        title.setSpan(new TextAppearanceSpan(getContext(),
                R.style.text_appearance_card_view_episode_number), programTitle == null ? 0
                : programTitle.length(), title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    return title;
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:20,代碼來源:DvrDetailsFragment.java

示例9: onBindViewHolder

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
@Override
    public void onBindViewHolder(FindSearchAdapter.ItemHolder holder, int position) {
//        String typeAndWhoStr = "<font color=\"#666666\"> ( "
//                + mDatas.get(position).getType()
//                + " via." + mDatas.get(position).getWho() + ")  </font>";

        int textColor = Color.parseColor("#4d000000");

        String textStr = mDatas.get(position).getDesc() + " ("
                + " via. " + mDatas.get(position).getWho() + ")";
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(textStr);
//        spannableStringBuilder.setSpan(new ForegroundColorSpan(textColor),
//                textStr.lastIndexOf("("), textStr.lastIndexOf(")") + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        spannableStringBuilder.setSpan(new TextAppearanceSpan(context, R.style.text_span_style),
                textStr.lastIndexOf("("), textStr.lastIndexOf(")") + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        holder.searchResultContentTv.setText(spannableStringBuilder);

//        holder.searchResultContentTv.setText(mDatas.get(position).getDesc() + " ("
//                + mDatas.get(position).getType()
//                + " via." + mDatas.get(position).getWho() + ")");

        // 將數據保存在itemView的Tag中,以便點擊時進行獲取
        holder.itemView.setTag(mDatas.get(position));
    }
 
開發者ID:absentm,項目名稱:myapplication,代碼行數:26,代碼來源:FindSearchAdapter.java

示例10: createCardItemText

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
private TextView createCardItemText(BaseGankData baseGankData) {
    TextView itemText = (TextView) LayoutInflater.from(this.context)
                                                 .inflate(R.layout.view_card_item, null);
    itemText.setPadding(this.cardItemPadding, this.cardItemPadding, this.cardItemPadding,
            this.cardItemPadding);
    String content = baseGankData.desc.trim() +
            "   " +
            String.format(this.viaModel, baseGankData.who);
    SpannableStringBuilder ssb = new SpannableStringBuilder(content);
    ssb.setSpan(new TextAppearanceSpan("serif", Typeface.ITALIC, this.viaTextSize,
                    this.viaColorStateList, this.viaColorStateList), content.indexOf(this.viaModelKey),
            content.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    itemText.setText(ssb);
    itemText.setTag(R.id.tag_card_item_url, baseGankData.url);
    itemText.setTag(R.id.tag_card_item_desc, baseGankData.desc.trim());
    itemText.setTag(R.id.tag_card_item_type, baseGankData.type);
    itemText.setOnClickListener(v -> {
        if (DailyDetailAdapter.this.onCardItemClickListener != null) {
            DailyDetailAdapter.this.onCardItemClickListener.onCardItemOnClick(
                    (String) v.getTag(R.id.tag_card_item_type),
                    (String) v.getTag(R.id.tag_card_item_desc),
                    (String) v.getTag(R.id.tag_card_item_url));
        }
    });
    return itemText;
}
 
開發者ID:CaMnter,項目名稱:EasyGank,代碼行數:27,代碼來源:DailyDetailAdapter.java

示例11: ContactsAdapter

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
/**
 * Instantiates a new Contacts Adapter.
 * @param context A context that has access to the app's layout.
 */
public ContactsAdapter(Context context) {
    super(context, null, 0);

    // Stores inflater for use later
    mInflater = LayoutInflater.from(context);

    // Loads a string containing the English alphabet. To fully localize the app, provide a
    // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file,
    // define a string with android:name="alphabet" and contents set to all of the
    // alphabetic characters in the language in their proper sort order, in upper case if
    // applicable.
    final String alphabet = context.getString(R.string.alphabet);

    // Instantiates a new AlphabetIndexer bound to the column used to sort contact names.
    // The cursor is left null, because it has not yet been retrieved.
    mAlphabetIndexer = new AlphabetIndexer(null, ContactsQuery.SORT_KEY, alphabet);

    // Defines a span for highlighting the part of a display name that matches the search
    // string
    highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight);
}
 
開發者ID:mojo1643,項目名稱:margarita,代碼行數:26,代碼來源:ContactFragment.java

示例12: highlight

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
private void highlight(String search, String originalText, TextView textView) {
    int startPos = originalText.toLowerCase(Locale.US).indexOf(search.toLowerCase(Locale.US));
    int endPos = startPos + search.length();

    if(startPos != -1){
        Spannable spannable = new SpannableString(originalText);
        ColorStateList yellowColor = new ColorStateList(new int[][]{new int[]{}}, new
                int[]{ContextCompat.getColor(mContext, R.color.overscroll_color)});
        TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1,
                yellowColor, null);

        spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(spannable);
    } else {
        textView.setText(originalText);
    }
}
 
開發者ID:ThatKawaiiGuy,項目名稱:Handbook_for_Melee,代碼行數:18,代碼來源:SearchAdapter.java

示例13: onCreate

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    storyLister = new StoryLister(this);
    storyList = (ListView) findViewById(R.id.storylist);
    storyListAdapter = new StoryListAdapter();

    storyList.setAdapter(storyListAdapter);

    titleStyle = new TextAppearanceSpan(this, R.style.story_title);
    authorStyle = new TextAppearanceSpan(this, R.style.story_author);
    headlineStyle = new TextAppearanceSpan(this, R.style.story_headline);
    descriptionStyle = new TextAppearanceSpan(this, R.style.story_description);
    saveTimeStyle = new TextAppearanceSpan(this, R.style.story_save_time);
    downloadTimeStyle = new TextAppearanceSpan(this, R.style.story_download_time);

    coverImageCache = new LruCache<String,Bitmap>(10);
}
 
開發者ID:qpliu,項目名稱:incant,代碼行數:20,代碼來源:Incant.java

示例14: formatPictureMessage

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
public CharSequence formatPictureMessage(Context context) {
    final TextAppearanceSpan notificationSubjectSpan = new TextAppearanceSpan(
            context, R.style.NotificationPrimaryText);

    // Change multiple newlines (with potential white space between), into a single new line
    final String message =
            !TextUtils.isEmpty(mMessage) ? mMessage.replaceAll("\\n\\s+", "\n") : "";

    // Show the subject or the message (if no subject)
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
    if (!TextUtils.isEmpty(mSubject)) {
        spannableStringBuilder.append(mSubject);
        spannableStringBuilder.setSpan(notificationSubjectSpan, 0, mSubject.length(), 0);
    }
    if (message.length() > 0 && spannableStringBuilder.length() == 0) {
        spannableStringBuilder.append(message);
        spannableStringBuilder.setSpan(notificationSubjectSpan, 0, message.length(), 0);
    }
    return spannableStringBuilder;
}
 
開發者ID:CommonQ,項目名稱:sms_DualCard,代碼行數:21,代碼來源:MessagingNotification.java

示例15: formatSenders

import android.text.style.TextAppearanceSpan; //導入依賴的package包/類
private static CharSequence formatSenders(Context context,
        ArrayList<NotificationInfo> senders) {
    final TextAppearanceSpan notificationSenderSpan = new TextAppearanceSpan(
            context, R.style.NotificationPrimaryText);

    String separator = context.getString(R.string.enumeration_comma);   // ", "
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
    int len = senders.size();
    for (int i = 0; i < len; i++) {
        if (i > 0) {
            spannableStringBuilder.append(separator);
        }
        spannableStringBuilder.append(senders.get(i).mSender.getName());
    }
    spannableStringBuilder.setSpan(notificationSenderSpan, 0,
            spannableStringBuilder.length(), 0);
    return spannableStringBuilder;
}
 
開發者ID:CommonQ,項目名稱:sms_DualCard,代碼行數:19,代碼來源:MessagingNotification.java


注:本文中的android.text.style.TextAppearanceSpan類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。