Example usage for android.widget TextView setSingleLine

List of usage examples for android.widget TextView setSingleLine

Introduction

In this page you can find the example usage for android.widget TextView setSingleLine.

Prototype

@android.view.RemotableViewMethod
public void setSingleLine(boolean singleLine) 

Source Link

Document

If true, sets the properties of this field (number of lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions.

Usage

From source file:de.winniehell.battlebeavers.ui.GameListActivity.java

private void addTab(final String pTag, final int pIndicator, final View pContent) {

    tabHost.addTab(//  w  w  w  .ja v  a2  s .  c om
            tabHost.newTabSpec(pTag).setIndicator(getString(pIndicator)).setContent(new TabContentFactory() {

                @Override
                public View createTabContent(final String tag) {
                    return pContent;
                }

            }));

    final View view = tabHost.getTabWidget().getChildTabViewAt(tabHost.getTabWidget().getTabCount() - 1);

    view.getLayoutParams().height *= 0.66;

    final TextView tabTitle = (TextView) view.findViewById(android.R.id.title);

    tabTitle.setGravity(Gravity.CENTER);
    tabTitle.setSingleLine(false);

    tabTitle.getLayoutParams().height = ViewGroup.LayoutParams.FILL_PARENT;
    tabTitle.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
}

From source file:com.simplecity.amp_library.ui.views.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)}./*ww  w .j  a v  a 2 s.c om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setTypeface(TypefaceManager.getInstance().getTypeface(TypefaceManager.SANS_SERIF_MEDIUM));
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setMinWidth(ResourceUtils.toPixels(72));
    textView.setSingleLine(true);

    // 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(R.attr.list_selector, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);

    // 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:org.mozilla.gecko.overlays.ui.ShareDialog.java

@Override
protected void onResume() {
    super.onResume();

    final Intent intent = getIntent();

    state = intent.getBooleanExtra(INTENT_EXTRA_DEVICES_ONLY, false) ? State.DEVICES_ONLY : State.DEFAULT;

    // If the Activity is being reused, we need to reset the state. Ideally, we create a
    // new instance for each call, but Android L breaks this (bug 1137928).
    sendTabList.switchState(SendTabList.State.LOADING);
    readingListButton.setBackgroundDrawable(readingListButtonDrawable);

    // The URL is usually hiding somewhere in the extra text. Extract it.
    final String extraText = ContextUtils.getStringExtra(intent, Intent.EXTRA_TEXT);
    if (TextUtils.isEmpty(extraText)) {
        abortDueToNoURL();/*from   www.  ja v  a  2  s .c  o m*/
        return;
    }

    final String pageUrl = new WebURLFinder(extraText).bestWebURL();
    if (TextUtils.isEmpty(pageUrl)) {
        abortDueToNoURL();
        return;
    }

    // Have the service start any initialisation work that's necessary for us to show the correct
    // UI. The results of such work will come in via the BroadcastListener.
    Intent serviceStartupIntent = new Intent(this, OverlayActionService.class);
    serviceStartupIntent.setAction(OverlayConstants.ACTION_PREPARE_SHARE);
    startService(serviceStartupIntent);

    // Start the slide-up animation.
    getWindow().setWindowAnimations(0);
    final Animation anim = AnimationUtils.loadAnimation(this, R.anim.overlay_slide_up);
    findViewById(R.id.sharedialog).startAnimation(anim);

    // If provided, we use the subject text to give us something nice to display.
    // If not, we wing it with the URL.

    // TODO: Consider polling Fennec databases to find better information to display.
    final String subjectText = intent.getStringExtra(Intent.EXTRA_SUBJECT);

    final String telemetryExtras = "title=" + (subjectText != null);
    if (subjectText != null) {
        ((TextView) findViewById(R.id.title)).setText(subjectText);
    }

    Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.SHARE_OVERLAY,
            telemetryExtras);

    title = subjectText;
    url = pageUrl;

    // Set the subtitle text on the view and cause it to marquee if it's too long (which it will
    // be, since it's a URL).
    final TextView subtitleView = (TextView) findViewById(R.id.subtitle);
    subtitleView.setText(pageUrl);
    subtitleView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    subtitleView.setSingleLine(true);
    subtitleView.setMarqueeRepeatLimit(5);
    subtitleView.setSelected(true);

    final View titleView = findViewById(R.id.title);

    if (state == State.DEVICES_ONLY) {
        bookmarkButton.setVisibility(View.GONE);
        readingListButton.setVisibility(View.GONE);

        titleView.setOnClickListener(null);
        subtitleView.setOnClickListener(null);
        return;
    }

    bookmarkButton.setVisibility(View.VISIBLE);
    readingListButton.setVisibility(View.VISIBLE);

    // Configure buttons.
    final View.OnClickListener launchBrowser = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ShareDialog.this.launchBrowser();
        }
    };

    titleView.setOnClickListener(launchBrowser);
    subtitleView.setOnClickListener(launchBrowser);

    final LocalBrowserDB browserDB = new LocalBrowserDB(getCurrentProfile());
    setButtonState(url, browserDB);
}

From source file:com.kaszubski.kamil.emmhelper.MainActivity.java

private void longTextTitleMode(boolean enabled) {
    try {//www. ja  va  2 s.co m
        Field titleField = Toolbar.class.getDeclaredField("mTitleTextView");
        titleField.setAccessible(enabled);
        TextView barTitleView = (TextView) titleField.get(toolbar);
        barTitleView.setEllipsize(enabled ? TextUtils.TruncateAt.START : TextUtils.TruncateAt.START);
        barTitleView.setFocusable(enabled);
        barTitleView.setFocusableInTouchMode(enabled);
        barTitleView.requestFocus();
        barTitleView.setSingleLine(enabled);
        barTitleView.setSelected(enabled);

    } catch (NoSuchFieldException e) {
        Log.e(TAG, "" + e);
    } catch (IllegalAccessException e) {
        Log.e(TAG, " " + e);
    }
}

From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java

@NonNull
private LinearLayout createBikeLine(@NonNull final BikeStation bikeStation, final boolean firstLine) {
    final LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);/*from  w w w. j a  v a2  s  .c  o  m*/
    final LinearLayout line = new LinearLayout(context);
    line.setOrientation(LinearLayout.HORIZONTAL);
    line.setLayoutParams(lineParams);

    // Left
    final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    final RelativeLayout left = new RelativeLayout(context);
    left.setLayoutParams(leftParam);

    final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA);
    int lineId = Util.generateViewId();
    lineIndication.setId(lineId);

    final RelativeLayout.LayoutParams availableParam = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    availableParam.addRule(RelativeLayout.RIGHT_OF, lineId);
    availableParam.setMargins(pixelsHalf, 0, 0, 0);

    final TextView boundCustomTextView = new TextView(context);
    boundCustomTextView.setText(activity.getString(R.string.bike_available_docks));
    boundCustomTextView.setSingleLine(true);
    boundCustomTextView.setLayoutParams(availableParam);
    boundCustomTextView.setTextColor(grey5);
    int availableId = Util.generateViewId();
    boundCustomTextView.setId(availableId);

    final RelativeLayout.LayoutParams availableValueParam = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    availableValueParam.addRule(RelativeLayout.RIGHT_OF, availableId);
    availableValueParam.setMargins(pixelsHalf, 0, 0, 0);

    final TextView amountBike = new TextView(context);
    final String text = firstLine ? activity.getString(R.string.bike_available_bikes)
            : activity.getString(R.string.bike_available_docks);
    boundCustomTextView.setText(text);
    final Integer data = firstLine ? bikeStation.getAvailableBikes() : bikeStation.getAvailableDocks();
    if (data == null) {
        amountBike.setText("?");
        amountBike.setTextColor(ContextCompat.getColor(context, R.color.orange));
    } else {
        amountBike.setText(String.valueOf(data));
        final int color = data == 0 ? R.color.red : R.color.green;
        amountBike.setTextColor(ContextCompat.getColor(context, color));
    }
    amountBike.setLayoutParams(availableValueParam);

    left.addView(lineIndication);
    left.addView(boundCustomTextView);
    left.addView(amountBike);
    line.addView(left);
    return line;
}

From source file:com.jinzht.pro.smarttablayout.SmartTabLayout.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  a 2s.  c o m*/
 */
protected TextView createDefaultTabView(CharSequence title) {
    TextView textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setText(title);
    textView.setTextColor(tabViewTextColors);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setSingleLine(true);
    UiHelp.textBold(textView);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (tabViewBackgroundResId != NO_ID) {
        textView.setBackgroundResource(tabViewBackgroundResId);
    } else 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(tabViewTextAllCaps);
    }

    textView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        textView.setMinWidth(tabViewTextMinWidth);
    }

    return textView;
}

From source file:com.sutromedia.android.core.PhotoActivity.java

public void onSetupView(View view, int viewId) {
    final IPhoto photo = getCurrentPhoto();
    if (photo != null) {

        int backgroundId = (viewId == R.layout.image_view_inside) ? R.drawable.attrib_inside
                : R.drawable.attrib_outside;

        Drawable background = getResources().getDrawable(backgroundId);
        background.setAlpha(155);//from   ww  w.  j  a  va 2s .c  o  m
        view.findViewById(R.image.licenseGroup).setBackgroundDrawable(background);
        setVisibility(view, R.image.caption, !mInSlideShow && !isSubsetOnEntry());
        TextView caption = (TextView) view.findViewById(R.image.caption);
        String entryName = photo.getEntryName();
        if (entryName != null) {
            entryName = entryName.replace(' ', '\u00A0');
            entryName += "\u00A0\u00A0\u25B6";
        }
        caption.setText(entryName);
        caption.setSingleLine(true);
        caption.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                onReceiveEntry(new NavigationDetailWeb(photo.getEntryId()));
            }
        });

        setVisibility(view, R.image.licenseGroup, !mInSlideShow);
        Integer[] icons = PhotoLicence.getIcons(photo);
        setImageView(view, R.image.license1, 0, icons);
        setImageView(view, R.image.license2, 1, icons);
        TextView owner = (TextView) view.findViewById(R.image.owner);
        if (icons.length > 0) {
            owner.setText(photo.getAuthor());
        } else {
            view.findViewById(R.image.licenseGroup).setVisibility(View.GONE);
        }

        String url = photo.getUrl();
        View licenceGroup = view.findViewById(R.image.licenseGroup);
        if (url != null && url.length() > 0) {
            owner.setTextColor(Color.rgb(0x19, 0x49, 0x90));
            owner.setTypeface(null, Typeface.BOLD);

            licenceGroup.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    onReceiveEntry(new NavigationWeb(photo.getUrl()));
                }
            });
        } else {
            owner.setTypeface(null, Typeface.NORMAL);
            owner.setTextColor(Color.WHITE);
            licenceGroup.setOnClickListener(null);
        }

        setupTouchOnPlayButton();
        setVisibility(R.image.play_slideshow, !mInSlideShow && mShowSlideShowControls);
        setVisibility(R.image.loading, mMissingPhoto);
        setVisibility(R.image.wait, mMissingPhoto && isOnline());

        String missingTextTemplate = getString(
                mMissingPhoto && isOnline() ? R.string.missing_photo : R.string.missing_not_online);
        String missingText = String.format(missingTextTemplate, mCurrentImage + 1, getImageCountInSet());

        setText(R.image.missing, missingText);
    }
}

From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java

private void handleBusRoute(@NonNull final FavoritesViewHolder holder, @NonNull final BusRoute busRoute) {
    holder.stationNameTextView.setText(busRoute.getId());
    holder.favoriteImage.setImageResource(R.drawable.ic_directions_bus_white_24dp);

    final List<BusDetailsDTO> busDetailsDTOs = new ArrayList<>();

    final Map<String, Map<String, List<BusArrival>>> busArrivals = favoritesData
            .getBusArrivalsMapped(busRoute.getId());
    for (final Entry<String, Map<String, List<BusArrival>>> entry : busArrivals.entrySet()) {
        // Build data for button outside of the loop
        final String stopName = entry.getKey();
        final String stopNameTrimmed = Util.trimBusStopNameIfNeeded(stopName);
        final Map<String, List<BusArrival>> value = entry.getValue();
        for (final String key2 : value.keySet()) {
            final BusArrival busArrival = value.get(key2).get(0);
            final String boundTitle = busArrival.getRouteDirection();
            final BusDirection.BusDirectionEnum busDirectionEnum = BusDirection.BusDirectionEnum
                    .fromString(boundTitle);
            final BusDetailsDTO busDetails = BusDetailsDTO.builder().busRouteId(busArrival.getRouteId())
                    .bound(busDirectionEnum.getShortUpperCase()).boundTitle(boundTitle)
                    .stopId(Integer.toString(busArrival.getStopId())).routeName(busRoute.getName())
                    .stopName(stopName).build();
            busDetailsDTOs.add(busDetails);
        }//from   w w  w.j a  va 2  s. c  om

        boolean newLine = true;
        int i = 0;

        for (final Entry<String, List<BusArrival>> entry2 : value.entrySet()) {
            final LinearLayout.LayoutParams containParams = getInsideParams(newLine, i == value.size() - 1);
            final LinearLayout container = new LinearLayout(context);
            container.setOrientation(LinearLayout.HORIZONTAL);
            container.setLayoutParams(containParams);

            // Left
            final LinearLayout.LayoutParams leftParams = new LinearLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            final RelativeLayout left = new RelativeLayout(context);
            left.setLayoutParams(leftParams);

            final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context,
                    TrainLine.NA);
            int lineId = Util.generateViewId();
            lineIndication.setId(lineId);

            final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId);
            destinationParams.setMargins(pixelsHalf, 0, 0, 0);

            final String bound = BusDirection.BusDirectionEnum.fromString(entry2.getKey()).getShortLowerCase();
            final String leftString = stopNameTrimmed + " " + bound;
            final SpannableString destinationSpannable = new SpannableString(leftString);
            destinationSpannable.setSpan(new RelativeSizeSpan(0.65f), stopNameTrimmed.length(),
                    leftString.length(), 0); // set size
            destinationSpannable.setSpan(new ForegroundColorSpan(grey5), 0, leftString.length(), 0); // set color

            final TextView boundCustomTextView = new TextView(context);
            boundCustomTextView.setText(destinationSpannable);
            boundCustomTextView.setSingleLine(true);
            boundCustomTextView.setLayoutParams(destinationParams);

            left.addView(lineIndication);
            left.addView(boundCustomTextView);

            // Right
            final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            rightParams.setMargins(marginLeftPixel, 0, 0, 0);
            final LinearLayout right = new LinearLayout(context);
            right.setOrientation(LinearLayout.VERTICAL);
            right.setLayoutParams(rightParams);

            final List<BusArrival> buses = entry2.getValue();
            final StringBuilder currentEtas = new StringBuilder();
            for (final BusArrival arri : buses) {
                currentEtas.append(" ").append(arri.getTimeLeftDueDelay());
            }
            final TextView arrivalText = new TextView(context);
            arrivalText.setText(currentEtas);
            arrivalText.setGravity(Gravity.END);
            arrivalText.setSingleLine(true);
            arrivalText.setTextColor(grey5);
            arrivalText.setEllipsize(TextUtils.TruncateAt.END);

            right.addView(arrivalText);

            container.addView(left);
            container.addView(right);

            holder.mainLayout.addView(container);

            newLine = false;
            i++;
        }
    }

    holder.mapButton.setText(activity.getString(R.string.favorites_view_buses));
    holder.detailsButton
            .setOnClickListener(new BusStopOnClickListener(activity, holder.parent, busDetailsDTOs));
    holder.mapButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {
            final Set<String> bounds = Stream.of(busDetailsDTOs).map(BusDetailsDTO::getBound)
                    .collect(Collectors.toSet());
            final Intent intent = new Intent(activity.getApplicationContext(), BusMapActivity.class);
            final Bundle extras = new Bundle();
            extras.putString(activity.getString(R.string.bundle_bus_route_id), busRoute.getId());
            extras.putStringArray(activity.getString(R.string.bundle_bus_bounds),
                    bounds.toArray(new String[bounds.size()]));
            intent.putExtras(extras);
            activity.startActivity(intent);
        }
    });
}

From source file:com.gh4a.IssueActivity.java

private void fillData() {
    new LoadCommentsTask(this).execute();

    Typeface boldCondensed = getApplicationContext().boldCondensed;

    ListView lvComments = (ListView) findViewById(R.id.list_view);
    // set details inside listview header
    LayoutInflater infalter = getLayoutInflater();
    LinearLayout mHeader = (LinearLayout) infalter.inflate(R.layout.issue_header, lvComments, false);
    mHeader.setClickable(false);// w  w w  .  j  av a2s .co  m

    lvComments.addHeaderView(mHeader, null, false);

    RelativeLayout rlComment = (RelativeLayout) findViewById(R.id.rl_comment);
    if (!isAuthorized()) {
        rlComment.setVisibility(View.GONE);
    }

    TextView tvCommentTitle = (TextView) mHeader.findViewById(R.id.comment_title);
    mCommentAdapter = new CommentAdapter(IssueActivity.this, new ArrayList<Comment>(), mIssue.getNumber(),
            mIssue.getState(), mRepoOwner, mRepoName);
    lvComments.setAdapter(mCommentAdapter);

    ImageView ivGravatar = (ImageView) mHeader.findViewById(R.id.iv_gravatar);
    aq.id(R.id.iv_gravatar).image(GravatarUtils.getGravatarUrl(mIssue.getUser().getGravatarId()), true, false,
            0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

    ivGravatar.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getUser().getLogin(), null);
        }
    });

    TextView tvExtra = (TextView) mHeader.findViewById(R.id.tv_extra);
    TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state);
    TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title);
    TextView tvDescTitle = (TextView) mHeader.findViewById(R.id.desc_title);
    tvDescTitle.setTypeface(getApplicationContext().boldCondensed);
    tvDescTitle.setTextColor(Color.parseColor("#0099cc"));

    tvCommentTitle.setTypeface(getApplicationContext().boldCondensed);
    tvCommentTitle.setTextColor(Color.parseColor("#0099cc"));
    tvCommentTitle
            .setText(getResources().getString(R.string.issue_comments) + " (" + mIssue.getComments() + ")");

    TextView tvDesc = (TextView) mHeader.findViewById(R.id.tv_desc);
    tvDesc.setMovementMethod(LinkMovementMethod.getInstance());

    TextView tvMilestone = (TextView) mHeader.findViewById(R.id.tv_milestone);

    ImageView ivComment = (ImageView) findViewById(R.id.iv_comment);
    if (Gh4Application.THEME == R.style.DefaultTheme) {
        ivComment.setImageResource(R.drawable.social_send_now_dark);
    }
    ivComment.setBackgroundResource(R.drawable.abs__list_selector_holo_dark);
    ivComment.setPadding(5, 2, 5, 2);
    ivComment.setOnClickListener(this);

    tvExtra.setText(mIssue.getUser().getLogin() + "\n" + pt.format(mIssue.getCreatedAt()));
    tvState.setTextColor(Color.WHITE);
    if ("closed".equals(mIssue.getState())) {
        tvState.setBackgroundResource(R.drawable.default_red_box);
        tvState.setText("C\nL\nO\nS\nE\nD");
    } else {
        tvState.setBackgroundResource(R.drawable.default_green_box);
        tvState.setText("O\nP\nE\nN");
    }
    tvTitle.setText(mIssue.getTitle());
    tvTitle.setTypeface(boldCondensed);

    boolean showInfoBox = false;
    if (mIssue.getAssignee() != null) {
        showInfoBox = true;
        TextView tvAssignee = (TextView) mHeader.findViewById(R.id.tv_assignee);
        tvAssignee.setText(mIssue.getAssignee().getLogin() + " is assigned");
        tvAssignee.setVisibility(View.VISIBLE);
        tvAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });

        ImageView ivAssignee = (ImageView) mHeader.findViewById(R.id.iv_assignee);

        aq.id(R.id.iv_assignee).image(GravatarUtils.getGravatarUrl(mIssue.getAssignee().getGravatarId()), true,
                false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

        ivAssignee.setVisibility(View.VISIBLE);
        ivAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });
    }

    if (mIssue.getMilestone() != null) {
        showInfoBox = true;
        tvMilestone.setText(
                getResources().getString(R.string.issue_milestone) + ": " + mIssue.getMilestone().getTitle());
    } else {
        tvMilestone.setVisibility(View.GONE);
    }

    String body = mIssue.getBodyHtml();
    if (!StringUtils.isBlank(body)) {
        HttpImageGetter imageGetter = new HttpImageGetter(this);
        body = HtmlUtils.format(body).toString();
        imageGetter.bind(tvDesc, body, mIssue.getNumber());
    }

    LinearLayout llLabels = (LinearLayout) findViewById(R.id.ll_labels);
    List<Label> labels = mIssue.getLabels();

    if (labels != null && !labels.isEmpty()) {
        showInfoBox = true;
        for (Label label : labels) {
            TextView tvLabel = new TextView(this);
            tvLabel.setSingleLine(true);
            tvLabel.setText(label.getName());
            tvLabel.setTextAppearance(this, R.style.default_text_small);
            tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor()));
            tvLabel.setPadding(5, 2, 5, 2);
            int r = Color.red(Color.parseColor("#" + label.getColor()));
            int g = Color.green(Color.parseColor("#" + label.getColor()));
            int b = Color.blue(Color.parseColor("#" + label.getColor()));
            if (r + g + b < 383) {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
            } else {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_light));
            }
            llLabels.addView(tvLabel);

            View v = new View(this);
            v.setLayoutParams(new LayoutParams(5, LayoutParams.WRAP_CONTENT));
            llLabels.addView(v);
        }
    } else {
        llLabels.setVisibility(View.GONE);
    }

    TextView tvPull = (TextView) mHeader.findViewById(R.id.tv_pull);
    if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) {
        showInfoBox = true;
        tvPull.setVisibility(View.VISIBLE);
        tvPull.setOnClickListener(this);
    }

    if (!showInfoBox) {
        RelativeLayout rl = (RelativeLayout) mHeader.findViewById(R.id.info_box);
        rl.setVisibility(View.GONE);
    }
}

From source file:com.liushengfan.test.customerviewgroup.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, SpannableString title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);/*from  w ww .  j  a  v a2s.  c o  m*/
    tab.setMovementMethod(LinkMovementMethod.getInstance());
    tab.setGravity(Gravity.CENTER);
    tab.setMaxLines(2);
    tab.setSingleLine(false);
    addTab(position, tab);
}