Example usage for android.widget TextView setTag

List of usage examples for android.widget TextView setTag

Introduction

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

Prototype

public void setTag(final Object tag) 

Source Link

Document

Sets the tag associated with this view.

Usage

From source file:org.adawaycn.util.HostsSourcesCursorAdapter.java

/**
 * Bind cursor to view using the checkboxes
 *//*  www .  j  ava2 s  .  com*/
@Override
public void bindView(View v, Context context, Cursor cursor) {
    CheckBox cBox = (CheckBox) v.findViewById(R.id.checkbox_list_two_checkbox);
    TextView hostnameTextView = (TextView) v.findViewById(R.id.checkbox_list_two_text);
    TextView lastModifiedTextView = (TextView) v.findViewById(R.id.checkbox_list_two_subtext);

    if (cBox != null) {
        // bind cursor position to tag of list item
        int cursorPosition = cursor.getPosition();
        cBox.setTag("checkbox_" + cursorPosition);
        hostnameTextView.setTag("url_" + cursorPosition);
        lastModifiedTextView.setTag("last_modified_" + cursorPosition);

        int enabledCol = cursor.getColumnIndexOrThrow(HostsSources.ENABLED);
        String enabled = cursor.getString(enabledCol);

        if (Integer.parseInt(enabled) == 1) {
            cBox.setChecked(true);
        } else {
            cBox.setChecked(false);
        }

        // set hostname
        int urlCol = cursor.getColumnIndex(HostsSources.URL);
        String url = cursor.getString(urlCol);
        hostnameTextView.setText(url);

        // set last modified
        int lastModifiedLocalCol = cursor.getColumnIndexOrThrow(HostsSources.LAST_MODIFIED_LOCAL);
        long lastModifiedLocal = cursor.getLong(lastModifiedLocalCol);
        int lastModifiedOnlineCol = cursor.getColumnIndexOrThrow(HostsSources.LAST_MODIFIED_ONLINE);
        long lastModifiedOnline = cursor.getLong(lastModifiedOnlineCol);
        lastModifiedTextView.setText(context.getString(R.string.hosts_last_modified_local) + " "
                + org.adawaycn.util.DateUtils.longToDateString(context, lastModifiedLocal) + ", "
                + context.getString(R.string.hosts_last_modified_online) + " "
                + DateUtils.longToDateString(context, lastModifiedOnline));

    }
}

From source file:com.linangran.tgfcapp.activities.MainActivity.java

private void inflateForumList(List<ForumBasicData> list, LinearLayout layout) {
    if (list == null || list.size() == 0) {
        return;/*ww w .  j  av a  2s  .c  o  m*/
    }
    LayoutInflater inflater = getLayoutInflater();
    for (int i = 0; i < list.size(); i++) {
        LinearLayout textLinearLayout = (LinearLayout) inflater.inflate(R.layout.forum_list_item, null);
        layout.addView(textLinearLayout);
        TextView textView = (TextView) textLinearLayout.findViewById(R.id.forum_list_item_textview);
        textView.setText(list.get(i).name);
        textView.setTag(list.get(i));
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ForumBasicData forumBasicData = (ForumBasicData) view.getTag();
                MainActivity.this.drawerLayout.closeDrawers();
                MainActivity.this.drawerLayout.post(new Runnable() {
                    @Override
                    public void run() {
                        MainActivity.this.drawerToggle.syncState();
                    }
                });
                MainActivity.this.forumListFragment.reload(forumBasicData);
            }
        });
    }
}

From source file:eu.liveGov.libraries.livegovtoolkit.activities_fragments.MapFragment.java

private void SetPopup(OverlayItem item) {
    if (item == null) {
        if (_popupView != null) {
            mOsmv.removeView(_popupView);
            mOsmv.setOnClickListener(null);
            mOsmv.setClickable(false);//from w w w  .  j  a v  a 2  s  .  c  o  m
        }
    } else {
        mOsmv.setOnClickListener(outsideClick);
        if (_popupView == null) {
            _popupView = getLayoutInflater(new Bundle()).inflate(R.layout.map_itempopup, mOsmv, false);

            ImageButton imbClose = (ImageButton) _popupView.findViewById(R.id.imbInfoClose);
            imbClose.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mOsmv.removeView(_popupView);
                }
            });

            _popupView.setOnClickListener(this);
        }
        mOsmv.removeView(_popupView);
        _popupView.setTag(item.getUid());
        TextView tv = (TextView) _popupView.findViewById(R.id.map_popup_title);

        tv.setText(item.getTitle());
        tv.setTag(item.getUid());
        TextView dv = (TextView) _popupView.findViewById(R.id.map_popup_description);
        dv.setText(item.getSnippet());
        dv.setTag(item.getUid());

        ImageView iv = (ImageView) _popupView.findViewById(R.id.map_popup_Thumbnail);

        ProposalObject proposalObject = ProposalHelper.getProposalById(Integer.parseInt(item.getUid()));

        iv.setImageBitmap(proposalObject.get_image(iv.getWidth() / 2, iv.getHeight() / 2));

        MapView.LayoutParams mapParams = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, item.getPoint(), MapView.LayoutParams.BOTTOM_CENTER, 0, 0);

        mOsmv.addView(_popupView, mapParams);
    }

}

From source file:com.github.mobile.util.HttpImageGetter.java

private HttpImageGetter hide(final TextView view, final Object id) {
    view.setText(null);/*from  w ww. ja  v a2s . co  m*/
    view.setVisibility(GONE);
    view.setTag(null);
    return this;
}

From source file:com.gh4a.activities.GistActivity.java

private void fillData(final Gist gist) {
    mGist = gist;/*www. java 2s  .  co  m*/

    if (gist.getOwner() != null) {
        getSupportActionBar().setSubtitle(gist.getOwner().getLogin());
    }

    TextView tvDesc = (TextView) findViewById(R.id.tv_desc);
    tvDesc.setText(TextUtils.isEmpty(gist.getDescription()) ? getString(R.string.gist_no_description)
            : gist.getDescription());

    TextView tvCreatedAt = (TextView) findViewById(R.id.tv_created_at);
    tvCreatedAt.setText(StringUtils.formatRelativeTime(this, gist.getCreatedAt(), true));

    Map<String, GistFile> files = gist.getFiles();
    if (files != null && !files.isEmpty()) {
        ViewGroup container = (ViewGroup) findViewById(R.id.file_container);
        LayoutInflater inflater = getLayoutInflater();

        container.removeAllViews();
        for (GistFile gistFile : files.values()) {
            TextView rowView = (TextView) inflater.inflate(R.layout.selectable_label, container, false);

            rowView.setText(gistFile.getFilename());
            rowView.setTextColor(UiUtils.resolveColor(this, android.R.attr.textColorPrimary));
            rowView.setOnClickListener(this);
            rowView.setTag(gistFile);
            container.addView(rowView);
        }
    } else {
        findViewById(R.id.file_card).setVisibility(View.GONE);
    }

    findViewById(R.id.tv_private).setVisibility(gist.isPublic() ? View.GONE : View.VISIBLE);
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Active_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);
    ll.setPadding(0, 0, 2, 1);/*from ww  w .  j a v  a 2  s. com*/
    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    ////////////////////////////////////////
    return ActivateColorize(ll, text, dr);
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Inactive_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);

    ll.setPadding(0, 0, 2, 1);// w w  w.  j a  va 2s . co  m

    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    /////////////////////////////////////
    return InActivateColorize(ll, text, dr);
}

From source file:com.frostwire.android.gui.adapters.SearchResultListAdapter.java

private void populateFilePart(View view, FileSearchResult sr) {
    ImageView fileTypeIcon = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon);
    fileTypeIcon.setImageResource(getFileTypeIconId());

    TextView adIndicator = findView(view, R.id.view_bittorrent_search_result_list_item_ad_indicator);
    adIndicator.setVisibility(View.GONE);

    TextView title = findView(view, R.id.view_bittorrent_search_result_list_item_title);
    title.setText(sr.getDisplayName());/*from ww  w  .j  ava  2 s .c o m*/

    TextView fileSize = findView(view, R.id.view_bittorrent_search_result_list_item_file_size);
    if (sr.getSize() > 0) {
        fileSize.setText(UIUtils.getBytesInHuman(sr.getSize()));
    } else {
        fileSize.setText("...");
    }

    TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra);
    extra.setText(FilenameUtils.getExtension(sr.getFilename()));

    TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds);
    seeds.setText("");

    String license = sr.getLicense().equals(Licenses.UNKNOWN) ? "" : " - " + sr.getLicense();

    TextView sourceLink = findView(view, R.id.view_bittorrent_search_result_list_item_text_source);
    sourceLink.setText(sr.getSource() + license); // TODO: ask for design
    sourceLink.setTag(sr.getDetailsUrl());
    sourceLink.setPaintFlags(sourceLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    sourceLink.setOnClickListener(linkListener);
}

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   w  w w . j av  a 2 s  .  co m
    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.brodev.socialapp.view.MarketPlaceDetail.java

private void initView() {

    ImageView userImage = (ImageView) this.findViewById(R.id.image_user);

    if (!"".equals(marketPlace.getUser_image_path())) {
        networkUntil.drawImageUrl(userImage, marketPlace.getUser_image_path(), R.drawable.loading);
    }/*from  w  ww  .  ja v  a 2  s.c  om*/

    userImage.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Intent intent = new Intent(MarketPlaceDetail.this, FriendTabsPager.class);
            intent.putExtra("user_id", marketPlace.getUser_id());
            startActivity(intent);
            return false;
        }
    });

    // set title
    TextView title = (TextView) this.findViewById(R.id.title);
    title.setText(marketPlace.getTitle());
    colorView.changeColorText(title, user.getColor());

    // set content
    TextView content = (TextView) this.findViewById(R.id.content);

    // interesting part starts from here here:
    Html.ImageGetter ig = imageGetter.create(0, marketPlace.getText(), content);

    content.setTag(0);
    content.setText(Html.fromHtml(marketPlace.getText(), ig, null));

    TextView timestampTxt = (TextView) findViewById(R.id.txtTimestamp);
    timestampTxt.setText(phraseManager.getPhrase(getApplicationContext(), "marketplace.posted_on"));
    TextView timestamp = (TextView) findViewById(R.id.time_stamp);
    timestamp.setText(marketPlace.getTime_stamp());
    TextView price = (TextView) this.findViewById(R.id.price);

    if (marketPlace.getPrice() == 0) {
        price.setText(phraseManager.getPhrase(getApplicationContext(), "marketplace.free"));
    } else {
        price.setText(marketPlace.getCurrency() + " " + marketPlace.getPrice());
    }

    TextView locationTxt = (TextView) findViewById(R.id.txtLocation);
    locationTxt.setText(phraseManager.getPhrase(getApplicationContext(), "marketplace.location"));
    TextView txtLocation = (TextView) this.findViewById(R.id.location);
    String location = marketPlace.getCountry_name();

    if (!marketPlace.getCountry_child_name().equals("")) {
        location += " > " + marketPlace.getCountry_child_name();
    }
    if (!marketPlace.getCity_name().equals("")) {
        location += " > " + marketPlace.getCity_name();
    }

    txtLocation.setText(location);
    // set short text
    TextView fullnameTxt = (TextView) findViewById(R.id.txtFullname);
    fullnameTxt.setText(phraseManager.getPhrase(getApplicationContext(), "marketplace.posted_by"));

    TextView shortText = (TextView) findViewById(R.id.fullName);
    shortText.setText(marketPlace.getFull_name());
    colorView.changeColorText(shortText, user.getColor());

    shortText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Intent intent = new Intent(MarketPlaceDetail.this, FriendTabsPager.class);
            intent.putExtra("user_id", marketPlace.getUser_id());
            startActivity(intent);
            return false;
        }
    });

    TextView total_like = (TextView) findViewById(R.id.total_like);
    total_like.setText(String.valueOf(marketPlace.getTotal_like()));
    colorView.changeColorText(total_like, user.getColor());

    TextView total_comment = (TextView) findViewById(R.id.total_comment);
    total_comment.setText(String.valueOf(marketPlace.getTotal_comment()));
    colorView.changeColorText(total_comment, user.getColor());

    ImageView likeImg = (ImageView) this.findViewById(R.id.likes_feed_txt);
    ImageView commentImg = (ImageView) this.findViewById(R.id.comments_feed_txt);
    colorView.changeColorLikeCommnent(likeImg, commentImg, user.getColor());

    //get list images
    if (!marketPlace.getImages().equals("")) {
        LinearLayout listImages = (LinearLayout) findViewById(R.id.listImages);
        JSONObject objOutputImage = null;
        try {
            JSONArray objImages = new JSONArray(marketPlace.getImages());
            for (int i = 0; i < objImages.length(); i++) {
                objOutputImage = objImages.getJSONObject(i);
                ImageView imageView = new ImageView(getApplicationContext());

                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                        (int) getResources().getDimension(R.dimen.marketplace_image),
                        (int) getResources().getDimension(R.dimen.marketplace_image));

                lp.setMargins(5, 5, 5, 0);

                imageView.setLayoutParams(lp);

                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                final String imagePath = objOutputImage.getString("image_path");
                networkUntil.drawImageUrl(imageView, imagePath, R.drawable.loading);

                imageView.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getApplicationContext(), ImageActivity.class);
                        intent.putExtra("image", imagePath);
                        intent.putExtra("title", marketPlace.getTitle());
                        startActivity(intent);
                    }
                });

                listImages.addView(imageView);

            }

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        this.findViewById(R.id.horizontalScrollView1).setVisibility(View.GONE);
        this.findViewById(R.id.marketplace_list_image_view).setVisibility(View.GONE);
    }

}