Set Text String to TextView - Android User Interface

Android examples for User Interface:TextView Value

Description

Set Text String to TextView

Demo Code


//package com.java2s;
import android.app.Activity;

import android.view.View;

import android.widget.TextView;

public class Main {
    public static Boolean SetTextStr(Activity activity, int nViewId,
            String strText) {//from w  w w.  j ava 2 s  . c  o  m
        TextView textView = (TextView) activity.findViewById(nViewId);
        if (textView == null) {
            return false;
        }
        textView.setText(strText);
        return true;
    }

    public static Boolean SetTextStr(View parentView, int nViewId,
            String strText) {
        TextView textView = (TextView) parentView.findViewById(nViewId);
        if (textView == null) {
            return false;
        }
        textView.setText(strText);
        return true;
    }
}

Related Tutorials