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:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java

public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) {
    final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance()
            .getCurrent().mShouldShowUiToAcceptTypedWord;
    final int stripWidth = addToDictionaryStrip.getWidth();
    final int width = shouldShowUiToAcceptTypedWord ? stripWidth : stripWidth - mDividerWidth - mPadding * 2;

    final TextView wordView = (TextView) addToDictionaryStrip.findViewById(R.id.word_to_save);
    wordView.setTextColor(mColorTypedWord);
    final int wordWidth = (int) (width * mCenterSuggestionWeight);
    final CharSequence wordToSave = getEllipsizedText(word, wordWidth, wordView.getPaint());
    final float wordScaleX = wordView.getTextScaleX();
    wordView.setText(wordToSave);/*from  ww  w .j a  v a2s  . c  o  m*/
    wordView.setTextScaleX(wordScaleX);
    setLayoutWeight(wordView, mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
    final int wordVisibility = shouldShowUiToAcceptTypedWord ? View.GONE : View.VISIBLE;
    wordView.setVisibility(wordVisibility);
    addToDictionaryStrip.findViewById(R.id.word_to_save_divider).setVisibility(wordVisibility);

    final Resources res = addToDictionaryStrip.getResources();
    final CharSequence hintText;
    final int hintWidth;
    final float hintWeight;
    final TextView hintView = (TextView) addToDictionaryStrip.findViewById(R.id.hint_add_to_dictionary);
    if (shouldShowUiToAcceptTypedWord) {
        hintText = res.getText(R.string.hint_add_to_dictionary_without_word);
        hintWidth = width;
        hintWeight = 1.0f;
        hintView.setGravity(Gravity.CENTER);
    } else {
        final boolean isRtlLanguage = (ViewCompat
                .getLayoutDirection(addToDictionaryStrip) == ViewCompat.LAYOUT_DIRECTION_RTL);
        final String arrow = isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW;
        final boolean isRtlSystem = SubtypeLocaleUtils.isRtlLanguage(res.getConfiguration().locale);
        final CharSequence hint = res.getText(R.string.hint_add_to_dictionary);
        hintText = (isRtlLanguage == isRtlSystem) ? (arrow + hint) : (hint + arrow);
        hintWidth = width - wordWidth;
        hintWeight = 1.0f - mCenterSuggestionWeight;
        hintView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
    }
    hintView.setTextColor(mColorAutoCorrect);
    final float hintScaleX = getTextScaleX(hintText, hintWidth, hintView.getPaint());
    hintView.setText(hintText);
    hintView.setTextScaleX(hintScaleX);
    setLayoutWeight(hintView, hintWeight, ViewGroup.LayoutParams.MATCH_PARENT);
}

From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java

private void initializeLegend(final TextView legend) {
    // From: http://stackoverflow.com/questions/6068197/utils-read-resource-text-file-to-string-java#answer-18897411
    String html = new Scanner(this.getClass().getResourceAsStream("/legend.html"), "UTF-8").useDelimiter("\\A")
            .next();/*w  ww  .  ja  v  a2  s . c om*/
    legend.setText(trimTrailingWhitespace(Html.fromHtml(html)));

    // Check MainActivity.PREF_SHOW_LEGEND and set legend visibility from that
    SharedPreferences preferences = getActivity().getPreferences(Context.MODE_PRIVATE);
    boolean showLegend = preferences.getBoolean(MainActivity.PREF_SHOW_LEGEND, true);
    legend.setVisibility(showLegend ? View.VISIBLE : View.GONE);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        int width = (int) spToPixels(LEGEND_WIDTH_LANDSCAPE_SP);

        // Put an upper bound on the legend width at 40% landscape screen width
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        //noinspection deprecation
        int landscapeWidth = Math.max(display.getWidth(), display.getHeight());
        if (width > landscapeWidth * 0.4) {
            width = (int) (landscapeWidth * 0.4);
        }

        legend.getLayoutParams().width = width;
    }
}

From source file:com.bangz.shotrecorder.RecordActivity.java

private void updateMode() {

    TextView vModeName = (TextView) findViewById(R.id.textmode);
    TextView vModeValName = (TextView) findViewById(R.id.textModePrefix);
    TextView vModeVal = (TextView) findViewById(R.id.textModeValue);

    vModeName.setText(strModeNames[mMode.ordinal()]);

    vModeValName.setText(strModeValNames[mMode.ordinal()]);

    if (mMode == MODE.VIRGINIA) {
        vModeVal.setText(String.format("%d", mMaxShots));
    } else if (mMode == MODE.PAR_TIME) {
        vModeVal.setText(String.format("%.1f", mMaxParTime));
    }//w w  w. j  a va2s  .  c o  m

    int visable = (mMode != MODE.COMSTOCK) ? View.VISIBLE : View.INVISIBLE;
    vModeValName.setVisibility(visable);
    vModeVal.setVisibility(visable);
}

From source file:br.com.mybaby.contatos.ContactDetailFragment.java

/**
  * Builds an address LinearLayout based on address information from the Contacts Provider.
  * Each address for the contact gets its own LinearLayout object; for example, if the contact
  * has three postal addresses, then 3 LinearLayouts are generated.
  *//from   w  w  w.  j  ava  2 s .co  m
  * @param addressType From
  * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#TYPE}
  * @param addressTypeLabel From
  * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#LABEL}
  * @param address From
  * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#FORMATTED_ADDRESS}
  * @return A LinearLayout to add to the contact details layout,
  *         populated with the provided address details.
  */
private LinearLayout buildAddressLayout(int addressType, String addressTypeLabel, final String address) {

    // Inflates the address layout
    final LinearLayout addressLayout = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.contatos_detail_item, mDetailsLayout, false);

    // Gets handles to the view objects in the layout
    final TextView headerTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_header);
    final TextView addressTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_item);
    final ImageButton viewAddressButton = (ImageButton) addressLayout.findViewById(R.id.button_view_address);

    // If there's no addresses for the contact, shows the empty view and message, and hides the
    // header and button.
    if (addressTypeLabel == null && addressType == 0) {
        headerTextView.setVisibility(View.GONE);
        viewAddressButton.setVisibility(View.GONE);
        addressTextView.setText(R.string.no_address);
    } else {
        // Gets postal address label type
        CharSequence label = StructuredPostal.getTypeLabel(getResources(), addressType, addressTypeLabel);

        // Sets TextView objects in the layout
        headerTextView.setText(label);
        addressTextView.setText(address);

        // Defines an onClickListener object for the address button
        viewAddressButton.setOnClickListener(new View.OnClickListener() {
            // Defines what to do when users click the address button
            @Override
            public void onClick(View view) {

                final Intent viewIntent = new Intent(Intent.ACTION_VIEW, constructGeoUri(address));

                // A PackageManager instance is needed to verify that there's a default app
                // that handles ACTION_VIEW and a geo Uri.
                final PackageManager packageManager = getActivity().getPackageManager();

                // Checks for an activity that can handle this intent. Preferred in this
                // case over Intent.createChooser() as it will still let the user choose
                // a default (or use a previously set default) for geo Uris.
                if (packageManager.resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
                    startActivity(viewIntent);
                } else {
                    // If no default is found, displays a message that no activity can handle
                    // the view button.
                    Toast.makeText(getActivity(), R.string.no_intent_found, Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
    return addressLayout;
}

From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java

private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    statusView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
    if (barcode == null) {
        barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.qr_scan));
    } else {// ww  w.j ava 2 s .  co m
        barcodeImageView.setImageBitmap(barcode);
    }

    TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
    formatTextView.setText(rawResult.getBarcodeFormat().toString());

    TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
    typeTextView.setText(resultHandler.getType().toString());

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
    TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
    timeTextView.setText(formattedTime);

    TextView metaTextView = (TextView) findViewById(R.id.meta_text_view);
    View metaTextViewLabel = findViewById(R.id.meta_text_view_label);
    metaTextView.setVisibility(View.GONE);
    metaTextViewLabel.setVisibility(View.GONE);
    Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata();
    if (metadata != null) {
        StringBuilder metadataText = new StringBuilder(20);
        for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) {
            if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
                metadataText.append(entry.getValue()).append('\n');
            }
        }
        if (metadataText.length() > 0) {
            metadataText.setLength(metadataText.length() - 1);
            metaTextView.setText(metadataText);
            metaTextView.setVisibility(View.VISIBLE);
            metaTextViewLabel.setVisibility(View.VISIBLE);
        }
    }

    TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
    CharSequence displayContents = resultHandler.getDisplayContents();
    contentsTextView.setText(displayContents);
    // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
    int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
    contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
    supplementTextView.setText("");
    supplementTextView.setOnClickListener(null);
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL,
            true)) {
        SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, resultHandler.getResult(),
                historyManager, this);
    }

    int buttonCount = resultHandler.getButtonCount();
    ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
    buttonView.requestFocus();
    for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
        TextView button = (TextView) buttonView.getChildAt(x);
        if (x < buttonCount) {
            button.setVisibility(View.VISIBLE);
            button.setText(resultHandler.getButtonText(x));
            button.setOnClickListener(new ResultButtonListener(resultHandler, x));
        } else {
            button.setVisibility(View.GONE);
        }
    }

    if (copyToClipboard && !resultHandler.areContentsSecure()) {
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        if (displayContents != null) {
            clipboard.setText(displayContents);
        }
    }
}

From source file:com.github.kanata3249.ffxieq.android.AugmentEditActivity.java

public void updateViews() {
    Equipment cur = getDAO().instantiateEquipment(mBaseID, mAugID);
    if (cur != null) {
        TextView tv;

        mBaseID = cur.getId();/*  w ww.  ja  va 2  s.c o  m*/
        cur.parseDescription();
        cur.removeAugmentCommentFromUnknownToken();
        tv = (TextView) findViewById(R.id.Name);
        if (tv != null) {
            tv.setText(cur.getName());
        }
        tv = (TextView) findViewById(R.id.Job);
        if (tv != null) {
            tv.setText(cur.getJob());
        }
        tv = (TextView) findViewById(R.id.Description);
        if (tv != null) {
            tv.setText(cur.getDescription());
        }
        tv = (TextView) findViewById(R.id.Level);
        if (tv != null) {
            tv.setText(((Integer) cur.getLevel()).toString());
        }
        tv = (TextView) findViewById(R.id.Race);
        if (tv != null) {
            tv.setText(cur.getRace());
        }
        tv = (TextView) findViewById(R.id.Ex);
        if (tv != null) {
            if (cur.isEx())
                tv.setVisibility(View.VISIBLE);
            else
                tv.setVisibility(View.INVISIBLE);
        }
        tv = (TextView) findViewById(R.id.Rare);
        if (tv != null) {
            if (cur.isRare())
                tv.setVisibility(View.VISIBLE);
            else
                tv.setVisibility(View.INVISIBLE);
        }

        EditText et = (EditText) findViewById(R.id.AugmentDescription);
        if (et != null) {
            if (mAugID >= 0)
                et.setText(cur.getAugment());
            else {
                String tmpl = cur.getAugmentComment();
                if (tmpl != null) {
                } else {
                    tmpl = "";
                }
                et.setText(tmpl);
            }
        }
    }
}

From source file:com.doubleTwist.drawerlib.exampleapp.ExampleFragment.java

private void setupSettingsPanel(int panel, View v) {
    TextView label1 = (TextView) v.findViewById(R.id.progress1_label);
    TextView label2 = (TextView) v.findViewById(R.id.progress2_label);
    TextView label3 = (TextView) v.findViewById(R.id.progress3_label);
    TextView label4 = (TextView) v.findViewById(R.id.progress4_label);

    SeekBar seek1 = (SeekBar) v.findViewById(R.id.progress1);
    SeekBar seek2 = (SeekBar) v.findViewById(R.id.progress2);
    SeekBar seek3 = (SeekBar) v.findViewById(R.id.progress3);
    SeekBar seek4 = (SeekBar) v.findViewById(R.id.progress4);

    boolean centerContent = panel == ADrawerLayout.NO_DRAWER;

    if (label1 != null)
        label1.setText(centerContent ? "X axis paralax [-1, 1]" : "Scale");
    if (seek1 != null) {
        seek1.setMax(1000);//from  w w  w.j  av a  2s.  co m
        seek1.setOnSeekBarChangeListener(this);
    }

    if (label2 != null)
        label2.setText(centerContent ? "Y axis paralax [-1, 1]" : "Alpha");
    if (seek2 != null) {
        seek2.setMax(1000);
        seek2.setOnSeekBarChangeListener(this);
    }

    if (label3 != null)
        label3.setText(centerContent ? "Content dim" : "Rot X");
    if (seek3 != null) {
        seek3.setMax(1000);
        seek3.setOnSeekBarChangeListener(this);
    }

    if (centerContent) {
        label4.setVisibility(View.GONE);
        seek4.setVisibility(View.GONE);
    } else {
        if (label4 != null)
            label4.setText("Rot Y");
        if (seek4 != null) {
            seek4.setMax(1000);
            seek4.setOnSeekBarChangeListener(this);
        }
    }
}

From source file:com.brq.wallet.activity.receive.ReceiveCoinsActivity.java

@Subscribe
public void syncStopped(SyncStopped event) {
    TextView tvRecv = (TextView) findViewById(R.id.tvReceived);
    TextView tvRecvWarning = (TextView) findViewById(R.id.tvReceivedWarningAmount);
    final WalletAccount selectedAccount = _mbwManager.getSelectedAccount();
    final List<TransactionSummary> transactionsSince = selectedAccount.getTransactionsSince(_receivingSince);
    final ArrayList<TransactionSummary> interesting = new ArrayList<TransactionSummary>();
    CurrencyValue sum = ExactBitcoinValue.ZERO;
    for (TransactionSummary item : transactionsSince) {
        if (item.toAddresses.contains(_address)) {
            interesting.add(item);//w  ww. ja va  2 s .c  o m
            sum = item.value;
        }
    }

    if (interesting.size() > 0) {
        tvRecv.setText(getString(R.string.incoming_payment)
                + Utils.getFormattedValueWithUnit(sum, _mbwManager.getBitcoinDenomination()));
        // if the user specified an amount, also check it if it matches up...
        if (!CurrencyValue.isNullOrZero(_amount)) {
            tvRecvWarning.setVisibility(sum.equals(_amount) ? View.GONE : View.VISIBLE);
        } else {
            tvRecvWarning.setVisibility(View.GONE);
        }
        tvRecv.setVisibility(View.VISIBLE);
        if (!sum.equals(_lastAddressBalance)) {
            NotificationManager notificationManager = (NotificationManager) this
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
                    .setSound(soundUri, AudioManager.STREAM_NOTIFICATION); //This sets the sound to play
            notificationManager.notify(0, mBuilder.build());

            _lastAddressBalance = sum;
        }
    } else {
        tvRecv.setVisibility(View.GONE);
    }
}

From source file:com.github.rutvijkumar.twittfuse.TwitterUtil.java

private void doReTweet(final Tweet tweet, final ImageButton rtAction, final TextView rtCount,
        final boolean hideZero) {

    client.postRT(String.valueOf(tweet.getUid()), new JsonHttpResponseHandler() {

        //               @Override
        //               public void onSuccess(int statusCode, Header[] headers,
        //                     JSONObject response) {
        //                  onSuccess(response);
        //               }
        //               @Override
        //               public void onFailure(int statusCode, Header[] headers,
        //                     Throwable throwable, JSONObject errorResponse) {
        //                  onFailure(throwable, errorResponse);
        //               }
        @Override//ww  w  .  jav  a  2  s  . c om
        public void onSuccess(JSONObject body) {
            final long newRTCount = tweet.getReTweetCount() + 1;

            tweet.setRetweeted(true);
            tweet.setReTweetCount(newRTCount);
            tweet.save();
            setRTView(true, rtAction);
            rtCount.setText(String.valueOf(newRTCount));
            if (hideZero) {
                if (newRTCount == 0) {
                    rtCount.setVisibility(View.INVISIBLE);
                } else {
                    rtCount.setVisibility(View.VISIBLE);
                }
            }
        }

        public void onFailure(Throwable e, JSONObject error) {
            Log.d("DEBUG", error.toString());
            Log.e("ERROR", "Exception while doing RT", e);
        }
    });

}

From source file:at.ac.uniklu.mobile.sportal.DashboardUpcomingDatesFragment.java

private void populateUpcomingDates() {
    long startTime = System.currentTimeMillis();
    TableLayout dateListTable = (TableLayout) getView().findViewById(R.id.dates);
    dateListTable.removeAllViews();//  ww  w  .  ja v  a  2 s  .  co m

    if (mDashboardModel.getDates().isEmpty()) {
        getView().findViewById(R.id.dates_empty).setVisibility(View.VISIBLE);
        return;
    } else {
        getView().findViewById(R.id.dates_empty).setVisibility(View.GONE);
    }

    Termin previousDate = null;
    for (Termin date : mDashboardModel.getDates()) {
        Date from = date.getDatum();

        View dateTableRow = getActivity().getLayoutInflater().inflate(R.layout.dashboard_date, dateListTable,
                false);
        TextView dateText = (TextView) dateTableRow.findViewById(R.id.text_date);
        TextView timeText = (TextView) dateTableRow.findViewById(R.id.text_time);
        TextView roomText = (TextView) dateTableRow.findViewById(R.id.text_room);
        TextView titleText = (TextView) dateTableRow.findViewById(R.id.text_title);

        dateText.setText(getString(R.string.calendar_date, from));
        timeText.setText(getString(R.string.calendar_time, from));
        roomText.setText(date.getRaum());
        titleText.setText(date.getTitleWithType());

        int color = 0;
        if (date.isStorniert()) {
            color = getResources().getColor(R.color.date_canceled);
        } else if (date.isNow()) {
            color = getResources().getColor(R.color.date_running);
        }
        if (color != 0) {
            dateText.setTextColor(color);
            timeText.setTextColor(color);
            roomText.setTextColor(color);
            titleText.setTextColor(color);
        }

        if (previousDate != null && Utils.isSameDay(previousDate.getDatum(), date.getDatum())) {
            dateText.setVisibility(View.INVISIBLE);
        }

        dateTableRow.setVisibility(View.INVISIBLE); // will be unhidden by #adjustDateListHeight()
        dateListTable.addView(dateTableRow);
        previousDate = date;
    }
    long deltaTime = System.currentTimeMillis() - startTime;
    Log.d(TAG, "populateUpcomingDates: " + deltaTime + "ms");
    adjustDateListHeight();
}