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.coincollection.ReorderCollections.java

private void hideUnsavedTextView() {

    TextView unsavedMessageView = (TextView) getView().findViewById(R.id.unsaved_message_textview_reorder);

    unsavedMessageView.setVisibility(View.GONE);
}

From source file:com.giovanniterlingen.windesheim.view.Fragments.ContentsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    NotificationCenter.getInstance().addObserver(this, NotificationCenter.downloadPending);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.downloadUpdated);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.downloadFinished);

    final ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_contents, container, false);

    recyclerView = viewGroup.findViewById(R.id.contents_recyclerview);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);

    final ProgressBar progressBar = viewGroup.findViewById(R.id.progress_bar);
    progressBar.setVisibility(View.VISIBLE);

    Bundle bundle = this.getArguments();

    ActionBar toolbar = ((NatschoolActivity) getActivity()).getSupportActionBar();
    if (toolbar != null) {
        String studyRouteName;// w w  w . j  ava 2 s.  c o m
        if (bundle != null && (studyRouteName = bundle.getString(STUDYROUTE_NAME)) != null
                && studyRouteName.length() != 0) {
            toolbar.setTitle(bundle.getString(STUDYROUTE_NAME));
        } else {
            toolbar.setTitle(getResources().getString(R.string.courses));
        }
        toolbar.setDisplayHomeAsUpEnabled(false);
        toolbar.setDisplayHomeAsUpEnabled(true);
    }
    new NatSchoolController((bundle == null ? -1 : (studyRouteId = bundle.getInt(STUDYROUTE_ID))),
            (bundle == null ? -1 : bundle.getInt(PARENT_ID, -1)), getActivity()) {
        @Override
        public void onFinished(final List<NatschoolContent> courses) {
            progressBar.setVisibility(View.GONE);
            TextView emptyTextView = viewGroup.findViewById(R.id.empty_textview);
            if (courses.isEmpty()) {
                emptyTextView.setVisibility(View.VISIBLE);
            } else {
                emptyTextView.setVisibility(View.GONE);
            }
            adapter = new NatschoolContentAdapter(getActivity(), courses) {
                @Override
                protected void onContentClick(NatschoolContent content, int position) {
                    if (content.url == null || content.url.length() == 0) {
                        Bundle bundle = new Bundle();
                        if (content.id == -1) {
                            bundle.putInt(STUDYROUTE_ID, content.studyRouteItemId);
                        } else {
                            bundle.putInt(STUDYROUTE_ID, studyRouteId);
                            bundle.putInt(PARENT_ID, content.id);
                        }
                        bundle.putString(STUDYROUTE_NAME, content.name);

                        ContentsFragment contentsFragment = new ContentsFragment();
                        contentsFragment.setArguments(bundle);

                        getActivity().getSupportFragmentManager().beginTransaction()
                                .replace(R.id.contents_fragment, contentsFragment, "").addToBackStack("")
                                .commit();
                    } else {
                        if (content.type == 1 || content.type == 3 || content.type == 11) {
                            createWebView(content.url);
                        } else if (content.type == 10) {
                            if (!content.downloading) {
                                new DownloadController(getActivity(), content.url, studyRouteId, content.id,
                                        position).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                            }
                        }
                    }
                }
            };
            recyclerView.setAdapter(adapter);
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    return viewGroup;
}

From source file:ch.timjahn.learningapp.ls.java

public void control(View view) {
    int progress = ((SeekBar) findViewById(R.id.seekBar)).getProgress();
    TextView tv = (TextView) findViewById(R.id.solution);
    tv.setVisibility(View.VISIBLE);
    switch (activeQ) {
    case 1://w  ww . j  av a 2  s  . c o  m
        if (activeA.equals(answer1)) {
            tv.setText("Richtig (~90|100).");
            tv.setTextColor(Color.parseColor("#00CC00"));
        } else {
            tv.setText("Falsch.");
            tv.setTextColor(Color.RED);
        }
        break;
    case 2:
        if (activeA.equals(answer2)) {
            tv.setText("Richtig (~45|100)");
            tv.setTextColor(Color.parseColor("#00CC00"));
        } else {
            tv.setText("Falsch.");
            tv.setTextColor(Color.RED);
        }
        break;
    }
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.view.TextModalInteractionView.java

@Override
public void doOnCreate(final Activity activity, Bundle onSavedInstanceState) {
    activity.setContentView(R.layout.apptentive_textmodal_interaction_center);

    TextView title = (TextView) activity.findViewById(R.id.title);
    if (interaction.getTitle() == null) {
        title.setVisibility(View.GONE);
    } else {/*from   www .j  av a 2 s .c  o m*/
        title.setText(interaction.getTitle());
    }
    TextView body = (TextView) activity.findViewById(R.id.body);
    if (interaction.getBody() == null) {
        body.setVisibility(View.GONE);
    } else {
        body.setText(interaction.getBody());
    }

    LinearLayout bottomArea = (LinearLayout) activity.findViewById(R.id.bottom_area);
    List<Action> actions = interaction.getActions().getAsList();
    boolean vertical;
    if (actions != null && !actions.isEmpty()) {
        int totalChars = 0;
        for (Action button : actions) {
            totalChars += button.getLabel().length();
        }
        if (actions.size() == 1) {
            vertical = false;
        } else if (actions.size() == 2) {
            vertical = totalChars > MAX_TEXT_LENGTH_FOR_TWO_BUTTONS;
        } else if (actions.size() == 3) {
            vertical = totalChars > MAX_TEXT_LENGTH_FOR_THREE_BUTTONS;
        } else if (actions.size() == 4) {
            vertical = totalChars > MAX_TEXT_LENGTH_FOR_FOUR_BUTTONS;
        } else {
            vertical = true;
        }
        if (vertical) {
            bottomArea.setOrientation(LinearLayout.VERTICAL);
        } else {
            bottomArea.setOrientation(LinearLayout.HORIZONTAL);
        }

        for (int i = 0; i < actions.size(); i++) {
            final Action buttonAction = actions.get(i);
            final int position = i;
            ApptentiveDialogButton button = new ApptentiveDialogButton(activity);
            button.setText(buttonAction.getLabel());
            switch (buttonAction.getType()) {
            case dismiss:
                button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        JSONObject data = new JSONObject();
                        try {
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId());
                            data.put(Action.KEY_LABEL, buttonAction.getLabel());
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position);
                        } catch (JSONException e) {
                            Log.e("Error creating Event data object.", e);
                        }
                        EngagementModule.engageInternal(activity, interaction,
                                TextModalInteraction.EVENT_NAME_DISMISS, data.toString());
                        activity.finish();
                    }
                });
                break;
            case interaction:
                button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        LaunchInteractionAction launchInteractionButton = (LaunchInteractionAction) buttonAction;
                        List<Invocation> invocations = launchInteractionButton.getInvocations();
                        String interactionIdToLaunch = null;
                        for (Invocation invocation : invocations) {
                            if (invocation.isCriteriaMet(activity)) {
                                interactionIdToLaunch = invocation.getInteractionId();
                                break;
                            }
                        }

                        Interaction invokedInteraction = null;
                        if (interactionIdToLaunch != null) {
                            Interactions interactions = InteractionManager.getInteractions(activity);
                            if (interactions != null) {
                                invokedInteraction = interactions.getInteraction(interactionIdToLaunch);
                            }
                        }

                        JSONObject data = new JSONObject();
                        try {
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId());
                            data.put(Action.KEY_LABEL, buttonAction.getLabel());
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position);
                            data.put(TextModalInteraction.EVENT_KEY_INVOKED_INTERACTION_ID,
                                    invokedInteraction == null ? JSONObject.NULL : invokedInteraction.getId());
                        } catch (JSONException e) {
                            Log.e("Error creating Event data object.", e);
                        }

                        EngagementModule.engageInternal(activity, interaction,
                                TextModalInteraction.EVENT_NAME_INTERACTION, data.toString());
                        if (invokedInteraction != null) {
                            EngagementModule.launchInteraction(activity, invokedInteraction);
                        }

                        activity.finish();
                    }
                });
                break;
            }
            bottomArea.addView(button);
        }
    } else {
        bottomArea.setVisibility(View.GONE);
    }
}

From source file:com.test.shopping.view.ProductDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /*/* w  w  w. ja v a  2  s. c o  m*/
     * Inflate the layout based on the current product details.
     * Fetch the product associated with the current position in product id list
     */
    ProductDataModel product = CacheUtil.getInstance(getActivity()).getProduct(mPosition);

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.product_detail, container, false);

    TextView productName = (TextView) rootView.findViewById(R.id.product_name);
    productName.setText(StringEscapeUtils.unescapeJava(product.getProductName()));

    String longDes = product.getLongDescription();
    TextView longDescLabel = (TextView) rootView.findViewById(R.id.long_description_label);
    TextView longDesc = (TextView) rootView.findViewById(R.id.long_description);
    if (longDes != null && longDes.length() > 0) {
        longDesc.setText(Jsoup.clean(longDes, Whitelist.simpleText()));
        longDesc.setVisibility(View.VISIBLE);
        longDescLabel.setVisibility(View.VISIBLE);
    } else {
        longDesc.setVisibility(View.INVISIBLE);
        longDescLabel.setVisibility(View.INVISIBLE);
    }

    TextView price = (TextView) rootView.findViewById(R.id.price);
    price.setText(product.getPrice());

    ImageView imageView = (ImageView) rootView.findViewById(R.id.image);
    ImageLoader loader = ConnectionUtil.getInstance(sContext).getImageLoader();
    loader.get(product.getProductImage(),
            ImageLoader.getImageListener(imageView, R.mipmap.ic_launcher, R.mipmap.ic_launcher));

    TextView ratingCountView = (TextView) rootView.findViewById(R.id.rating_count);

    ratingCountView.setText("(" + String.valueOf(product.getReviewCount() + ")"));

    RatingBar bar = (RatingBar) rootView.findViewById(R.id.ratingBar);

    bar.setRating((int) product.getReviewRating());
    bar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    TextView inStock = (TextView) rootView.findViewById(R.id.inStock);
    if (product.isInStock()) {
        inStock.setTextColor(getResources().getColor(android.R.color.holo_green_dark));
        inStock.setText(R.string.in_stock_label);
    } else {
        inStock.setTextColor(getResources().getColor(android.R.color.holo_red_dark));
        inStock.setText(R.string.out_of_stock_label);
    }

    return rootView;
}

From source file:com.bt.download.android.gui.adapters.SearchResultListAdapter.java

protected void populateAppiaPart(View view, AppiaSearchResult sr) {
    TextView adIndicator = findView(view, R.id.view_bittorrent_search_result_list_item_ad_indicator);
    adIndicator.setVisibility(View.VISIBLE);

    TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra);
    extra.setText(sr.getCategoryName() + " : " + sr.getDescription());

    //TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds);
    //String license = sr.getLicense().equals(License.UNKNOWN) ? "" : " - " + sr.getLicense();

    TextView sourceLink = findView(view, R.id.view_bittorrent_search_result_list_item_text_source);
    sourceLink.setText(sr.getSource());//from  w w w . j  a  va2  s  . c om
    sourceLink.setTag(sr.getDetailsUrl());
    sourceLink.setPaintFlags(sourceLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    sourceLink.setOnClickListener(linkListener);
}

From source file:com.brq.wallet.activity.main.BalanceFragment.java

private void updateUi() {
    if (!isAdded()) {
        return;// w  ww .j  a va 2 s. c o m
    }
    if (_mbwManager.getSelectedAccount().isArchived()) {
        return;
    }
    WalletAccount account = Preconditions.checkNotNull(_mbwManager.getSelectedAccount());
    CurrencyBasedBalance balance;
    try {
        balance = Preconditions.checkNotNull(account.getCurrencyBasedBalance());
    } catch (IllegalArgumentException ex) {
        _mbwManager.reportIgnoredException(ex);
        balance = CurrencyBasedBalance.ZERO_BITCOIN_BALANCE;
    }

    // Hide spend button if not canSpend()
    int visibility = account.canSpend() ? View.VISIBLE : View.GONE;
    _root.findViewById(R.id.btSend).setVisibility(visibility);

    updateUiKnownBalance(balance);

    // Set BTC rate
    if (!_mbwManager.hasFiatCurrency()) {
        // No fiat currency selected by user
        _root.findViewById(R.id.tvBtcRate).setVisibility(View.INVISIBLE);
    } else if (_exchangeRatePrice == null) {
        // We have no price, exchange not available
        TextView tvBtcRate = (TextView) _root.findViewById(R.id.tvBtcRate);
        tvBtcRate.setVisibility(View.VISIBLE);
        tvBtcRate.setText(getResources().getString(R.string.exchange_source_not_available,
                _mbwManager.getExchangeRateManager().getCurrentExchangeSourceName()));
    } else {
        TextView tvBtcRate = (TextView) _root.findViewById(R.id.tvBtcRate);
        tvBtcRate.setVisibility(View.VISIBLE);
        String currency = _mbwManager.getFiatCurrency();
        String converted = Utils.getFiatValueAsString(Constants.ONE_BTC_IN_SATOSHIS, _exchangeRatePrice);
        tvBtcRate.setText(getResources().getString(R.string.btc_rate, currency, converted,
                _mbwManager.getExchangeRateManager().getCurrentExchangeSourceName()));
    }
}

From source file:tmnt.wheresyourcar.ParkActivity.java

public void setMeterTime(View view) {
    Button btn = (Button) view;
    ((ViewManager) btn.getParent()).removeView(btn);
    TimePicker num = (TimePicker) findViewById(R.id.num_pick);
    num.setVisibility(View.VISIBLE);
    TextView text = (TextView) findViewById(R.id.minutes);
    text.setVisibility(View.VISIBLE);
}

From source file:net.olejon.spotcommander.PlaylistsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Allow landscape?
    if (!mTools.allowLandscape())
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Intent/*from   w  w w  .jav  a  2s .c o  m*/
    final Intent intent = getIntent();

    // Computer
    final long computerId = mTools.getSharedPreferencesLong(
            "WIDGET_" + intent.getStringExtra(WidgetLarge.WIDGET_LARGE_INTENT_EXTRA) + "_COMPUTER_ID");

    final String[] computer = mTools.getComputer(computerId);

    // Layout
    setContentView(R.layout.activity_playlists);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.playlists_toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
    toolbar.setTitle(getString(R.string.playlists_title));

    setSupportActionBar(toolbar);

    // Progress bar
    mProgressBar = (ProgressBar) findViewById(R.id.playlists_progressbar);
    mProgressBar.setVisibility(View.VISIBLE);

    // Listview
    mListView = (ListView) findViewById(R.id.playlists_list);

    // Get playlists
    final Cache cache = new DiskBasedCache(getCacheDir(), 0);

    final Network network = new BasicNetwork(new HurlStack());

    final RequestQueue requestQueue = new RequestQueue(cache, network);

    requestQueue.start();

    final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
            computer[0] + "/playlists.php?get_playlists_as_json", null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    requestQueue.stop();

                    try {
                        final ArrayList<String> playlistNames = new ArrayList<>();

                        final Iterator<?> iterator = response.keys();

                        while (iterator.hasNext()) {
                            String key = (String) iterator.next();

                            playlistNames.add(key);
                        }

                        Collections.sort(playlistNames, new Comparator<String>() {
                            @Override
                            public int compare(String string1, String string2) {
                                return string1.compareToIgnoreCase(string2);
                            }
                        });

                        for (String playlistName : playlistNames) {
                            mPlaylistUris.add(response.getString(playlistName));
                        }

                        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(mContext,
                                R.layout.activity_playlists_list_item, playlistNames);

                        mProgressBar.setVisibility(View.GONE);

                        mListView.setAdapter(arrayAdapter);
                        mListView.setVisibility(View.VISIBLE);

                        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                mTools.remoteControl(computerId, "shuffle_play_uri",
                                        mPlaylistUris.get(position));

                                finish();
                            }
                        });
                    } catch (Exception e) {
                        mProgressBar.setVisibility(View.GONE);

                        final TextView textView = (TextView) findViewById(R.id.playlists_error);
                        textView.setVisibility(View.VISIBLE);
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    requestQueue.stop();

                    mProgressBar.setVisibility(View.GONE);

                    final TextView textView = (TextView) findViewById(R.id.playlists_error);
                    textView.setVisibility(View.VISIBLE);
                }
            }) {
        @Override
        public HashMap<String, String> getHeaders() {
            final HashMap<String, String> hashMap = new HashMap<>();

            if (!computer[1].equals("") && !computer[2].equals(""))
                hashMap.put("Authorization", "Basic "
                        + Base64.encodeToString((computer[1] + ":" + computer[2]).getBytes(), Base64.NO_WRAP));

            return hashMap;
        }
    };

    jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(2500, 0, 0));

    requestQueue.add(jsonObjectRequest);
}

From source file:com.google.android.apps.watchme.EventsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View listView = inflater.inflate(R.layout.list_fragment, container, false);
    mGridView = (GridView) listView.findViewById(R.id.grid_view);
    TextView emptyView = (TextView) listView.findViewById(android.R.id.empty);
    mGridView.setEmptyView(emptyView);/*from w  w  w . ja  va2 s. c  o  m*/
    emptyView.setVisibility(View.GONE);
    ImageView downimage = (ImageView) listView.findViewById(R.id.down);
    mGridView.setEmptyView(downimage);
    return listView;
}