Example usage for android.widget TextView setVisibility

List of usage examples for android.widget TextView setVisibility

Introduction

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

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:de.geeksfactory.opacclient.frontend.InfoFragment.java

public void load() {
    wvInfo = (WebView) view.findViewById(R.id.wvInfo);
    TextView tvErr = (TextView) view.findViewById(R.id.tvErr);
    wvInfo.loadData(getString(R.string.loading), "text/html", null);

    try {/*from   ww w.  ja v a  2  s .  c o m*/
        String infoUrl = app.getLibrary().getInformation();
        if (infoUrl == null || infoUrl.equals("null")) {
            wvInfo.setVisibility(View.GONE);
            tvErr.setVisibility(View.VISIBLE);
            tvErr.setText(R.string.info_unsupported);
        } else if (infoUrl.startsWith("http")) {
            wvInfo.loadUrl(infoUrl);
        } else {
            wvInfo.loadUrl(app.getLibrary().getData().getString("baseurl") + infoUrl);
        }
    } catch (JSONException e) {
        e.printStackTrace();
        wvInfo.setVisibility(View.GONE);
        tvErr.setVisibility(View.VISIBLE);
        tvErr.setText(R.string.info_error);
    }
}

From source file:nl.terr.tabweave.TabWeave.java

public void fillData(List<JSONObject> lTabs) {
    // Create an array to specify the fields we want to display in the list (only TITLE)
    String[] from = new String[] { SyncWeave.KEY_TITLE, SyncWeave.KEY_URL, SyncWeave.KEY_ROWID };

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[] { R.id.title, R.id.url };

    int iBrowserInstances = lTabs.size();
    MatrixCursor matrixCursor = new MatrixCursor(from);

    int iTabId = 0;

    // Show "No tabs" message
    TextView tvNoTabs = (TextView) findViewById(R.id.no_tabs);
    tvNoTabs.setVisibility(View.VISIBLE);

    try {/*from ww  w  . j av a  2  s  .  co  m*/
        for (int iWeaveBrowserInstance = 0; iWeaveBrowserInstance < iBrowserInstances; iWeaveBrowserInstance++) {
            int iNumberTabs = lTabs.get(iWeaveBrowserInstance).getJSONArray("tabs").length();

            // Hide "No tabs" message
            if (iNumberTabs > 0) {
                tvNoTabs.setVisibility(View.INVISIBLE);
            }

            for (int iWeaveTab = 0; iWeaveTab < iNumberTabs; iWeaveTab++) {
                matrixCursor.newRow()
                        .add(lTabs.get(iWeaveBrowserInstance).getJSONArray("tabs").getJSONObject(iWeaveTab)
                                .getString("title"))
                        .add(lTabs.get(iWeaveBrowserInstance).getJSONArray("tabs").getJSONObject(iWeaveTab)
                                .getJSONArray("urlHistory").getString(0))
                        .add(iTabId);

                iTabId++;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();

        AlertDialog alert = createAlertDialog(this, e.getClass().toString(), e.getMessage());
        alert.show();
    }

    ListAdapter listAdapter = new SimpleCursorAdapter(this, // Context
            R.layout.tab_row, // Specify the row template to use (here, two columns bound to the two retrieved cursor rows).
            matrixCursor, from, to);

    setListAdapter(listAdapter);
}

From source file:eu.cyberkat.h2owirelessbalancecheck.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Button button = (Button) this.findViewById(R.id.button1);
    final ProgressBar pb = getMyProgBar();
    pb.setMax(100);//from  w  w w. ja  v  a2  s . c  o m
    final AutoScaleTextView text1 = (AutoScaleTextView) this.findViewById(R.id.textView2);
    final TextView text2 = (TextView) this.findViewById(R.id.textView3);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        text1.setVisibility(View.VISIBLE);
        text2.setVisibility(View.GONE);
        Scaling = true;
    } else {
        text1.setVisibility(View.GONE);
        text2.setVisibility(View.VISIBLE);
        Scaling = false;
    }
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            final EditText phonenum = getPhoneNum();
            String number = phonenum.getText().toString();
            new GrabTheBalance().execute(number);
        }
    });
}

From source file:co.nerdart.ourss.adapter.FeedsCursorAdapter.java

@Override
protected void bindChildView(View view, Context context, Cursor cursor) {
    view.findViewById(R.id.indicator).setVisibility(View.INVISIBLE);

    TextView textView = ((TextView) view.findViewById(android.R.id.text1));
    long feedId = cursor.getLong(idPosition);
    if (feedId == mSelectedFeedId) {
        view.setBackgroundResource(android.R.color.holo_blue_dark);
    } else {/*from  w w  w .  java  2  s.c om*/
        view.setBackgroundResource(android.R.color.transparent);
    }

    TextView updateTextView = ((TextView) view.findViewById(android.R.id.text2));
    updateTextView.setVisibility(View.VISIBLE);

    if (cursor.isNull(errorPosition)) {
        long timestamp = cursor.getLong(lastUpdateColumn);

        // Date formatting is expensive, look at the cache
        String formattedDate = mFormattedDateCache.get(timestamp);
        if (formattedDate == null) {
            Date date = new Date(timestamp);

            formattedDate = context.getString(R.string.update) + COLON
                    + (timestamp == 0 ? context.getString(R.string.never)
                            : new StringBuilder(Constants.DATE_FORMAT.format(date)).append(' ')
                                    .append(Constants.TIME_FORMAT.format(date)));
            mFormattedDateCache.put(timestamp, formattedDate);
        }

        updateTextView.setText(formattedDate);
    } else {
        updateTextView.setText(new StringBuilder(context.getString(R.string.error)).append(COLON)
                .append(cursor.getString(errorPosition)));
    }

    byte[] iconBytes = cursor.getBlob(iconPosition);

    if (iconBytes != null && iconBytes.length > 0) {
        Bitmap bitmap = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);

        if (bitmap != null && bitmap.getHeight() > 0 && bitmap.getWidth() > 0) {
            int bitmapSizeInDip = UiUtils.dpToPixel(18);

            if (bitmap.getHeight() != bitmapSizeInDip) {
                bitmap = Bitmap.createScaledBitmap(bitmap, bitmapSizeInDip, bitmapSizeInDip, false);
            }
            textView.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(context.getResources(), bitmap),
                    null, null, null);
        } else {
            textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        }
    } else {
        view.setTag(null);
        textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    }

    int unreadCount;
    synchronized (mUnreadItemsByFeed) {
        unreadCount = mUnreadItemsByFeed.get(feedId);
    }

    if (unreadCount > 0) {
        textView.setEnabled(true);
        updateTextView.setEnabled(true);
    } else {
        textView.setEnabled(false);
        updateTextView.setEnabled(false);
    }
    textView.setText(
            (cursor.isNull(namePosition) ? cursor.getString(linkPosition) : cursor.getString(namePosition))
                    + (unreadCount > 0 ? " (" + unreadCount + ")" : ""));

    View sortView = view.findViewById(R.id.sortitem);
    if (!sortViews.contains(sortView)) { // as we are reusing views, this is fine
        sortViews.add(sortView);
    }
    sortView.setVisibility(feedSort ? View.VISIBLE : View.GONE);
}

From source file:com.glanznig.beepme.view.ViewSampleFragment.java

private void populateFields() {

    if (sampleId != 0L) {
        Sample s = new SampleTable(getActivity().getApplicationContext()).getSampleWithTags(sampleId);

        TextView timestamp = (TextView) getView().findViewById(R.id.view_sample_timestamp);
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
        timestamp.setText(dateFormat.format(s.getTimestamp()));

        TextView title = (TextView) getView().findViewById(R.id.view_sample_title);
        if (s.getTitle() != null && s.getTitle().length() > 0) {
            title.setText(s.getTitle());
        } else {//from w  w w.  j a  va2s .c o m
            title.setText(getString(R.string.sample_untitled));
        }

        TextView description = (TextView) getView().findViewById(R.id.view_sample_description);
        if (s.getDescription() != null && s.getDescription().length() > 0) {
            description.setTextSize(14);
            description.setText(s.getDescription());
        } else {
            description.setTextSize(12);
            // not editable any more
            if ((Calendar.getInstance().getTimeInMillis() - s.getTimestamp().getTime()) >= 24 * 60 * 60
                    * 1000) {
                description.setText(getString(R.string.sample_no_description));
            } else {
                description.setText(getString(R.string.sample_no_description_editable));
            }
        }

        boolean hasKeywordTags = false;

        FlowLayout keywordHolder = (FlowLayout) getView().findViewById(R.id.view_sample_keyword_container);
        keywordHolder.removeAllViews();

        Iterator<Tag> i = s.getTags().iterator();
        Tag tag = null;

        while (i.hasNext()) {
            tag = i.next();
            if (tag.getVocabularyId() == 1) {

                TextView view = new TextView(getView().getContext());
                view.setText(tag.getName());

                final float scale = getResources().getDisplayMetrics().density;
                int textPaddingLeftRight = 6;
                int textPaddingTopBottom = 2;

                view.setPadding((int) (textPaddingLeftRight * scale + 0.5f),
                        (int) (textPaddingTopBottom * scale + 0.5f),
                        (int) (textPaddingLeftRight * scale + 0.5f),
                        (int) (textPaddingTopBottom * scale + 0.5f));
                view.setBackgroundColor(getResources().getColor(R.color.bg_keyword));

                keywordHolder.addView(view);
                hasKeywordTags = true;
            }
        }

        TextView noKeywordsView = (TextView) getView().findViewById(R.id.view_sample_no_keywords);
        if (!hasKeywordTags) {
            keywordHolder.setVisibility(View.GONE);
            noKeywordsView.setVisibility(View.VISIBLE);
            // not editable any more (after 1 day)
            if ((Calendar.getInstance().getTimeInMillis() - s.getTimestamp().getTime()) >= 24 * 60 * 60
                    * 1000) {
                noKeywordsView.setText(getString(R.string.sample_no_keywords));
            } else {
                noKeywordsView.setText(getString(R.string.sample_no_keywords_editable));
            }
        } else {
            noKeywordsView.setVisibility(View.GONE);
            keywordHolder.setVisibility(View.VISIBLE);
        }

        photoView = (SamplePhotoView) getView().findViewById(R.id.view_sample_photo);
        photoView.setRights(false, false); // read only
        DisplayMetrics metrics = getView().getContext().getResources().getDisplayMetrics();

        int thumbnailSize;
        if (!isLandscape()) {
            photoView.setFrameWidth(LayoutParams.MATCH_PARENT);
            thumbnailSize = (int) (metrics.widthPixels / metrics.density + 0.5f);
        } else {
            thumbnailSize = (int) (metrics.heightPixels / metrics.density + 0.5f);
        }

        String thumbnailUri = PhotoUtils.getThumbnailUri(s.getPhotoUri(), thumbnailSize);
        if (thumbnailUri != null) {
            File thumb = new File(thumbnailUri);
            if (thumb.exists()) {
                ImgLoadHandler handler = new ImgLoadHandler(photoView);
                PhotoUtils.getAsyncBitmap(getView().getContext(), thumbnailUri, handler);
            } else {
                Handler handler = new Handler(this);
                PhotoUtils.generateThumbnails(getView().getContext(), s.getPhotoUri(), handler);
            }
        } else {
            photoView.unsetPhoto();
        }
    }
}

From source file:io.github.protino.codewatch.ui.ProfileActivity.java

private void removeViewIfNoData(TextView view) {
    String text = view.getText().toString();
    if (text.isEmpty() || text.contentEquals("null")) {
        view.setVisibility(View.GONE);
    }//from w  w  w  . j av  a 2  s .  c  o m
}

From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java

private void showResultDialog(final String res) {
    final AlertDialog d = new AlertDialog.Builder(this).create();
    d.show();//  ww  w  .j  av a2 s  .c om
    d.setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_common_dialog_notitle"));
    d.setCanceledOnTouchOutside(false);

    TextView tv_content = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_content"));
    String content = getResources().getString(BaseUtils.getResourceValue("string",
            TextUtils.isEmpty(res) ? "oasisgames_sdk_epin_notice_3" : "oasisgames_sdk_epin_notice_4"));
    content = content.replace("DIAMOND", res);
    tv_content.setText(content);

    TextView tv_sure = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_sure"));
    tv_sure.setText(
            getResources().getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_common_btn_sure")));
    tv_sure.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            if (!TextUtils.isEmpty(res))
                et_code.setText("");
            d.dismiss();
        }
    });
    TextView tv_cancle = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_cancle"));
    tv_cancle.setVisibility(View.GONE);

    TextView tv_text = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_text"));
    tv_text.setVisibility(View.GONE);

}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPCompaniesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.fragment_companies, container, false);

    setHasOptionsMenu(true);/* w  w w. j  ava 2s. c o  m*/

    recyclerView = (ObservableRecyclerView) mView.findViewById(R.id.scroll);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setHasFixedSize(false);

    recyclerView.setAdapter(new CompaniesCellAdapter(getActivity()));

    Fragment parentFragment = getParentFragment();
    ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
    if (viewGroup != null) {
        recyclerView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
        if (parentFragment instanceof ObservableScrollViewCallbacks) {
            recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
        }
    }

    final String searchText = ((MainActivity) getActivity()).getSearchString();
    final TextView notificationTextView = (TextView) mView.findViewById(R.id.companies_txt_notificationBox);

    if (searchText != null && !searchText.isEmpty()) {
        notificationTextView.setText(getResources().getString(R.string.notification_Search, searchText));
        notificationTextView.setVisibility(View.VISIBLE);
    } else {
        notificationTextView.setVisibility(View.GONE);
    }

    return mView;
}

From source file:com.enadein.carlogbook.core.BaseActivity.java

protected boolean validateView(int errorViewId, EditText editView) {
    TextView errorView = (TextView) findViewById(errorViewId);
    double valueDouble = CommonUtils.getRawDouble(editView.getText().toString());
    boolean result = 10000000.d >= valueDouble;

    errorView.setVisibility((!result) ? View.VISIBLE : View.GONE);
    return result;
}

From source file:com.bonsai.btcreceive.ReceiveFragment.java

public void hideAddress() {
    TextView addrtv = (TextView) getActivity().findViewById(R.id.receive_addr);
    addrtv.setVisibility(View.GONE);

    ImageView iv = (ImageView) getActivity().findViewById(R.id.receive_qr_view);
    iv.setVisibility(View.GONE);//  w w w.j  av  a2s . c  o  m

    // Clear the HDAddress associated with this address.
    mHDAddress = null;
    mTransitioned = false;

    mFiatAmountEditText.setFocusable(true);
    mFiatAmountEditText.setFocusableInTouchMode(true);
    mBTCAmountEditText.setFocusable(true);
    mBTCAmountEditText.setFocusableInTouchMode(true);
}