Set TextView Text And Visibility - Android User Interface

Android examples for User Interface:TextView Value

Description

Set TextView Text And Visibility

Demo Code


//package com.java2s;

import android.view.View;

import android.widget.TextView;

public class Main {
    public static void SetTextAndVisibility(TextView view, CharSequence text) {
        SetTextAndVisibility(view, text, View.GONE);
    }//from  w  w w  . j a  v  a 2 s.  c  om

    public static void SetTextAndVisibility(TextView view,
            CharSequence text, int visibilityIfEmpty) {
        if (text == null || text.length() == 0) {
            view.setVisibility(visibilityIfEmpty);
        } else {
            view.setVisibility(View.VISIBLE);
            view.setText(text);
        }
    }
}

Related Tutorials