Example usage for android.widget TextView getVisibility

List of usage examples for android.widget TextView getVisibility

Introduction

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

Prototype

@ViewDebug.ExportedProperty(mapping = { @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"),
        @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"),
        @ViewDebug.IntToString(from = GONE, to = "GONE") })
@Visibility
public int getVisibility() 

Source Link

Document

Returns the visibility status for this view.

Usage

From source file:com.starwood.anglerslong.LicenseActivity.java

/******************************************************************************
 * Reads in all of the items in that should be populated.
 ******************************************************************************/
private void populateTabs(boolean isRestart) {
    try {//ww  w. j  a  v  a2  s.  c o m
        JsonStorage jsonStorage = new JsonStorage(getApplicationContext());
        String wholeString = jsonStorage.loadTabs();
        if (!wholeString.equals(""))
            isLicensePopulated = true;
        populateLicense(wholeString, isRestart);
        if (numItems == 0) {
            isCreateTextViewSet = false;
            createTextView();
        } else {
            try {
                TextView tv = (TextView) findViewById(0);
                if (tv.getVisibility() == View.VISIBLE || numItems > 0) {
                    tv.setVisibility(View.GONE);
                    isCreateTextViewSet = false;
                }
            } catch (NullPointerException e) {
                Log.d("KENNY", "The text view was null.");
            }
        }

    } catch (IOException | JSONException e) {
        if (!isLicensePopulated)
            isArrayEmpty = true;
        createTextView();
        e.printStackTrace();
    }
}

From source file:io.github.hidroh.materialistic.ComposeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mParentId = getIntent().getStringExtra(EXTRA_PARENT_ID);
    if (TextUtils.isEmpty(mParentId)) {
        finish();// ww w . j  a v  a 2  s . com
        return;
    }
    AppUtils.setStatusBarColor(getWindow(), ContextCompat.getColor(this, R.color.blackT12));
    setContentView(R.layout.activity_compose);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
    mEditText = (EditText) findViewById(R.id.edittext_body);
    if (savedInstanceState == null) {
        mEditText.setText(Preferences.getDraft(this, mParentId));
    }
    findViewById(R.id.empty).setOnClickListener(v -> mEditText.requestFocus());
    findViewById(R.id.empty).setOnLongClickListener(v -> {
        mEditText.requestFocus();
        return mEditText.performLongClick();
    });
    mParentText = getIntent().getStringExtra(EXTRA_PARENT_TEXT);
    if (!TextUtils.isEmpty(mParentText)) {
        findViewById(R.id.quote).setVisibility(View.VISIBLE);
        final TextView toggle = (TextView) findViewById(R.id.toggle);
        final TextView textView = (TextView) findViewById(R.id.text);
        AppUtils.setTextWithLinks(textView, AppUtils.fromHtml(mParentText));
        toggle.setOnClickListener(v -> {
            if (textView.getVisibility() == View.VISIBLE) {
                toggle.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_expand_more_white_24dp, 0);
                textView.setVisibility(View.GONE);

            } else {
                toggle.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_expand_less_white_24dp, 0);
                textView.setVisibility(View.VISIBLE);
            }
        });
    }
}

From source file:ru.valle.btc.MainActivityTest.java

private String getText(final Activity activity, final int id) {
    FutureTask<String> task = new FutureTask<>(new Callable<String>() {
        @Override//from   w ww .ja  v a 2  s .co  m
        public String call() throws Exception {
            TextView textView = ((TextView) activity.findViewById(id));
            return textView.getVisibility() == View.VISIBLE ? getString(textView) : null;
        }
    });
    activity.runOnUiThread(task);
    try {
        return task.get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.freshdigitable.udonroad.UserInfoActivity.java

private void setUpAppbar() {
    binding.userInfoToolbar.setTitle("");

    final TextView toolbarTitle = binding.userInfoToolbarTitle;
    binding.userInfoAppbarLayout.addOnOffsetChangedListener(new OnOffsetChangedListener() {
        private boolean isTitleVisible = toolbarTitle.getVisibility() == View.VISIBLE;

        @Override/*from  ww  w  . j a va  2 s.  c o  m*/
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            final int totalScrollRange = appBarLayout.getTotalScrollRange();
            final float percent = (float) Math.abs(verticalOffset) / (float) totalScrollRange;
            if (percent > 0.9) {
                if (!isTitleVisible) {
                    startAnimation(toolbarTitle, View.VISIBLE);
                    isTitleVisible = true;
                }
            } else {
                if (isTitleVisible) {
                    startAnimation(toolbarTitle, View.INVISIBLE);
                    isTitleVisible = false;
                }
            }
        }

        private void startAnimation(View v, int visibility) {
            AlphaAnimation animation = (visibility == View.VISIBLE) ? new AlphaAnimation(0f, 1f)
                    : new AlphaAnimation(1f, 0f);
            animation.setDuration(200);
            animation.setFillAfter(true);
            v.startAnimation(animation);
        }
    });
}

From source file:org.gots.ui.SeedActivity.java

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

    Bundle bundle = this.getArguments();
    seedId = bundle.getInt(GOTS_SEED_ID);

    if (seedId <= 0) {
        Log.e("SeedActivity", "You must provide a org.gots.seed.id as an Extra Int");
        return v;
    }/*from w w w . j av  a2  s .  c om*/

    mSeed = seedManager.getSeedById(seedId);

    final TextView seedDescriptionEnvironnement = (TextView) v.findViewById(R.id.IdSeedDescriptionEnvironment);
    seedDescriptionEnvironnement.setText(Html.fromHtml(mSeed.getDescriptionGrowth()));

    TextView seedDescriptionTitle = (TextView) v.findViewById(R.id.IdSeedDescriptionEnvironmentTitle);
    seedDescriptionTitle.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (seedDescriptionEnvironnement.getVisibility() == View.VISIBLE)
                seedDescriptionEnvironnement.setVisibility(View.GONE);
            else
                seedDescriptionEnvironnement.setVisibility(View.VISIBLE);
        }
    });

    final TextView seedDescriptionCulture = (TextView) v.findViewById(R.id.IdSeedDescriptionCulture);
    seedDescriptionCulture.setText(Html.fromHtml(mSeed.getDescriptionCultivation()));
    TextView seedDescriptionCultureTitle = (TextView) v.findViewById(R.id.IdSeedDescriptionCultureTitle);
    seedDescriptionCultureTitle.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (seedDescriptionCulture.getVisibility() == View.VISIBLE)
                seedDescriptionCulture.setVisibility(View.GONE);
            else
                seedDescriptionCulture.setVisibility(View.VISIBLE);
        }
    });

    final TextView seedDescriptionEnnemi = (TextView) v.findViewById(R.id.IdSeedDescriptionEnnemi);
    seedDescriptionEnnemi.setText(Html.fromHtml(mSeed.getDescriptionDiseases()));
    TextView seedDescriptionEnnemiTitle = (TextView) v.findViewById(R.id.IdSeedDescriptionEnnemiTitle);
    seedDescriptionEnnemiTitle.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (seedDescriptionEnnemi.getVisibility() == View.VISIBLE)
                seedDescriptionEnnemi.setVisibility(View.GONE);
            else
                seedDescriptionEnnemi.setVisibility(View.VISIBLE);
        }
    });

    final TextView seedDescriptionCultureHarvest = (TextView) v.findViewById(R.id.IdSeedDescriptionHarvest);
    seedDescriptionCultureHarvest.setText(Html.fromHtml(mSeed.getDescriptionHarvest()));
    TextView seedDescriptionHarvest = (TextView) v.findViewById(R.id.IdSeedDescriptionHarvestTitle);
    seedDescriptionHarvest.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (seedDescriptionCultureHarvest.getVisibility() == View.VISIBLE)
                seedDescriptionCultureHarvest.setVisibility(View.GONE);
            else
                seedDescriptionCultureHarvest.setVisibility(View.VISIBLE);
        }
    });

    return v;
}

From source file:com.android.tv.menu.MenuLayoutManager.java

private void setTempTitleView(TextView dest, TextView src) {
    dest.setVisibility(View.VISIBLE);
    dest.setText(src.getText());/*from w  w w. ja v  a 2  s . com*/
    dest.setTranslationY(0.0f);
    if (src.getVisibility() == View.VISIBLE) {
        dest.setAlpha(src.getAlpha());
        dest.setScaleX(src.getScaleX());
        dest.setScaleY(src.getScaleY());
    } else {
        dest.setAlpha(0.0f);
        dest.setScaleX(1.0f);
        dest.setScaleY(1.0f);
    }
    View parent = (View) src.getParent();
    dest.setLeft(src.getLeft() + parent.getLeft());
    dest.setRight(src.getRight() + parent.getLeft());
    dest.setTop(src.getTop() + parent.getTop());
    dest.setBottom(src.getBottom() + parent.getTop());
}

From source file:com.ntsync.android.sync.activities.ImportActivity.java

public void onCreateEnd(boolean success, boolean cancel, ImportError error, int importedCount,
        int availableEnd) {
    if (success) {
        finish();/* w w w  .j a  v  a  2s . c  o m*/
    } else {
        TextView textView = (TextView) findViewById(R.id.message_bottom);
        if (!cancel && error != null) {
            int msgId;
            switch (error) {
            case DB_ERROR:
                msgId = R.string.import_activity_dberror;
                break;
            default:
                msgId = R.string.import_activity_failed;
                break;
            }

            textView.setVisibility(View.VISIBLE);
            textView.setText(getText(msgId));
        } else {
            textView.setVisibility(View.GONE);
        }

        if (textView.getVisibility() == View.VISIBLE) {
            textView.setError(getText(R.string.import_activity_retry));
        } else {
            textView.setError(null);
        }
    }
}

From source file:com.sanbo.moveonapp.TabsActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        loaded = savedInstanceState.getBoolean("loaded", false);
        showLang = savedInstanceState.getBoolean("showLang", false);
        showDialog = savedInstanceState.getBoolean("showDialog", false);
    }/* w  w w  . j av a2s  . co  m*/
    try {
        LocationSynchronizer mLocationSynchronizer = LocationSynchronizer
                .getInstance((SynchronizableActivity) getSynchronizableActivity());
        myLocation = mLocationSynchronizer.getLocation();
        if (myLocation == null)
            MoveOnCroutonStyle.croutonAlert(this, R.string.error_location_NETWORK);
    } catch (Exception e) {
        Log.e(Config.LOGTAG, "TabsActivity.onResume getting show Defaults from SharedPreferences");
    }
    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_tabs);
    // Show the Up button in the action bar:
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    context = this;

    //ProgressBar while is filling the list
    myProgressBar = (ProgressBar) findViewById(R.id.progress);
    isEmpty = (TextView) findViewById(R.id.empty);
    //Vector of pages
    Vector<View> pages = new Vector<View>();
    //List Message showing description on click show Exp List
    listviewMessage = new ListView(context);
    listviewMessage.setDivider(context.getResources().getDrawable(R.drawable.line));
    listviewMessage.setDividerHeight(1);
    //List Message showing complete description, onClickItem
    listviewMessageExp = new ListView(context);
    listviewMessageExp.setDivider(context.getResources().getDrawable(R.drawable.line));
    listviewMessageExp.setDividerHeight(1);

    // two pages
    pages.add(listviewMessage);
    pages.add(listviewMessageExp);

    // our adapter for pager
    vp = (ViewPager) findViewById(R.id.pager);
    CustomPagerAdapter adapter = new CustomPagerAdapter(context, pages);
    vp.setAdapter(adapter);

    //Execute asyntask (we can send string array)
    new BackgroundTask().execute("SOMETHING");
    //mlistAdapter = new ListViewAdapterMessage(context, myPublic.getListAllMessages());
    //listviewMessageExp.setAdapter(mlistAdapter);
    //listviewMessage.setAdapter(mlistAdapter);

    // click event for each row of the list
    listviewMessage.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // arg2 = the id of the item in our view (List/Grid) that we clicked
            // arg3 = the id of the item that we have clicked
            // if we didn't assign any id for the Object (Book) the arg3 value is 0
            // That means if we comment, aBookDetail.setBookIsbn(i); arg3 value become 0
            if (Config.DEBUG)
                Toast.makeText(getApplicationContext(),
                        "You clicked on position : " + arg2 + " and id : " + arg3, Toast.LENGTH_LONG).show();
            TextView c = (TextView) arg1.findViewById(R.id.textDescription);
            int changeit = (View.VISIBLE != c.getVisibility()) ? View.VISIBLE : View.GONE;
            c.setVisibility(changeit);
            listviewMessage.setSelection(arg2);
        }

    });

    // Objects to change on the fly
    this.rl = (RelativeLayout) findViewById(R.id.rl_tabs);
    this.txt_hello = (TextView) findViewById(R.id.tabsMessage);
    this.txt_version = (TextView) findViewById(R.id.tabsVersionNumber);
    this.txt_textList = (TextView) findViewById(R.id.textList);
    this.img_icon = (ImageView) findViewById(R.id.tabsImageIcon);
    this.button1 = (Button) findViewById(R.id.button1);
    this.button2 = (Button) findViewById(R.id.button2);
    this.button3 = (Button) findViewById(R.id.button3);
    this.button4 = (Button) findViewById(R.id.button4);
    this.button5 = (Button) findViewById(R.id.button5);

    loadLocale();
    //Configuration Language
    if (loaded) {
        showButtons();
    } else {
        // instance of timer and myTimerTask
        txt_hello.setVisibility(View.VISIBLE);
        txt_hello.setText(R.string.dataBaseLoaded);
        txt_version.setVisibility(View.VISIBLE);
        img_icon.setVisibility(View.VISIBLE);
        timer = new Timer();
        myTimerTask = new MyTimerTask();
        timer.schedule(myTimerTask, 2000);
    }

    ((Button) findViewById(R.id.button1)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Open activity of routes not impelented on v1.0
            if (Config.DEBUG)
                Toast.makeText(v.getContext(),
                        v.getContext().getResources().getString(R.string.routesNotImplemented),
                        Toast.LENGTH_SHORT).show();
            MoveOnCroutonStyle.croutonWarn(TabsActivity.this, R.string.routesNotImplemented);
            //MoveOnCroutonStyle.croutonAlert(TabsActivity.this, R.string.error_loadingDB);
            //MoveOnCroutonStyle.croutonFly(TabsActivity.this, R.string.error_loadingDB);
            //MoveOnCroutonStyle.croutonInfo(TabsActivity.this, R.string.error_loadingDB);
            //MoveOnCroutonStyle.croutonConfirm(TabsActivity.this, R.string.error_loadingDB);

            //Initialize route Activity
            //startActivity(new Intent(context, ItineraryActivity.class));

        }
    });
    ((Button) findViewById(R.id.button2)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Open tabs User showing LINES
            if (Config.DEBUG)
                Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.lines),
                        Toast.LENGTH_SHORT).show();
            savingState.setTabInit(AppConstants.TAB_A);
            //Open tabs showwing LINES
            startActivity(new Intent(context, AppMainTabActivity.class));
        }
    });
    ((Button) findViewById(R.id.button3)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Open tabs User showing STATIONS
            if (Config.DEBUG)
                Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.stations),
                        Toast.LENGTH_SHORT).show();
            savingState.setTabInit(AppConstants.TAB_B);
            //Open tabs showwing LINES
            startActivity(new Intent(context, AppMainTabActivity.class));
        }
    });
    ((Button) findViewById(R.id.button4)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Open tabs User showing FAVORITES
            if (Config.DEBUG)
                Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.favourits),
                        Toast.LENGTH_SHORT).show();
            savingState.setTabInit(AppConstants.TAB_D);
            //Open tabs showwing LINES
            startActivity(new Intent(context, AppMainTabActivity.class));
        }
    });
    ((Button) findViewById(R.id.button5)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Open tabs User showing NEARBY STATION
            if (Config.DEBUG)
                Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.nearbystations),
                        Toast.LENGTH_SHORT).show();
            savingState.setTabInit(AppConstants.TAB_C);
            //Open tabs showwing LINES
            startActivity(new Intent(context, AppMainTabActivity.class));
        }
    });

    if (showLang)
        menuLanguage();
    if (showDialog)
        showDialog();

}

From source file:org.chromium.chrome.browser.omnibox.SuggestionView.java

/**
 * Sets a description line for the omnibox suggestion.
 *
 * @param str The description text./*ww  w . j  av  a2  s  . c  o  m*/
 * @param isUrl Whether this text is a URL (as opposed to a normal string).
 */
private void showDescriptionLine(Spannable str, boolean isUrl) {
    TextView textLine = mContentsView.mTextLine2;
    if (textLine.getVisibility() != VISIBLE) {
        textLine.setVisibility(VISIBLE);
    }
    textLine.setText(str, BufferType.SPANNABLE);

    // Force left-to-right rendering for URLs. See UrlBar constructor for details.
    if (isUrl) {
        textLine.setTextColor(URL_COLOR);
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR);
    } else {
        textLine.setTextColor(getStandardFontColor());
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT);
    }
}

From source file:org.nativescript.widgets.TabLayout.java

private void setupItem(LinearLayout ll, TextView textView, ImageView imgView, TabItemSpec tabItem) {
    float density = getResources().getDisplayMetrics().density;

    if (tabItem.iconId != 0) {
        imgView.setImageResource(tabItem.iconId);
        imgView.setVisibility(VISIBLE);/*  www.  j a v  a 2  s .c  om*/
    } else if (tabItem.iconDrawable != null) {
        imgView.setImageDrawable(tabItem.iconDrawable);
        imgView.setVisibility(VISIBLE);
    } else {
        imgView.setVisibility(GONE);
    }

    if (tabItem.title != null && !tabItem.title.isEmpty()) {
        textView.setText(tabItem.title);
        textView.setVisibility(VISIBLE);
    } else {
        textView.setVisibility(GONE);
    }

    if (imgView.getVisibility() == VISIBLE && textView.getVisibility() == VISIBLE) {
        ll.setMinimumHeight((int) (LARGE_MIN_HEIGHT * density));
    } else {
        ll.setMinimumHeight((int) (SMALL_MIN_HEIGHT * density));
    }

    if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
    }
}