Example usage for android.widget TextView setText

List of usage examples for android.widget TextView setText

Introduction

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

Prototype

@android.view.RemotableViewMethod
public final void setText(@StringRes int resid) 

Source Link

Document

Sets the text to be displayed using a string resource identifier.

Usage

From source file:Main.java

public static void updateInfoPanel(TextView infoPanel, int color, String message) {
    if (infoPanel != null) {
        infoPanel.setTextColor(color);//from   w ww .  ja  va 2 s  .c  o m
        infoPanel.setText(message);
        infoPanel.setSelected(true);
        infoPanel.invalidate();
    }
}

From source file:Main.java

public static void setText(TextView textView, String text) {
    if (textView != null) {
        if (text == null)
            text = "";
        textView.setText(text);
    } else {/*from   w  w w. j a va 2 s .c  o m*/
        throw new IllegalArgumentException("A view is null in your parameters.");
    }
}

From source file:Main.java

public static void setText(Activity activity, int viewId, String text) {
    if (activity != null) {
        android.widget.TextView view = (android.widget.TextView) activity.findViewById(viewId);
        if (view != null)
            view.setText(text);
    }//from w  w w  .ja  va 2s  . c om
}

From source file:Main.java

public static void appendToStartOfLog(TextView log, String appendThis) {
    String currentLog = log.getText().toString();
    currentLog = currentLog + "\n" + appendThis;
    log.setText(currentLog);
}

From source file:android.databinding.testapp.adapter.MultiArgTestAdapter.java

@BindingAdapter({ "android:class1str", "android:class2str" })
public static void setBoth(TextView view, String str1, String str2) {
    view.setText(join(str1, str2));
}

From source file:android.databinding.testapp.adapter.MultiArgTestAdapter.java

@BindingAdapter({ "android:class1" })
public static void setClass1(TextView view, MultiBindingClass1 class1) {
    view.setText(class1.getValue());
}

From source file:android.databinding.testapp.adapter.MultiArgTestAdapter.java

@BindingAdapter("android:class2")
public static void setClass2(TextView view, MultiBindingClass2 class2) {
    view.setText(class2.getValue());
}

From source file:Main.java

public static void updateStatusBar(TextView statusBarMain, int color, String message) {
    if (statusBarMain != null) {
        statusBarMain.setTextColor(color);
        statusBarMain.setText(message);
        statusBarMain.setSelected(true);
        statusBarMain.invalidate();/*from  w ww .  ja va 2 s .c  om*/
    }
}

From source file:Main.java

public static void mapToAndroidLayoutMapper(Class classObj, Map map, String prefixStr, View view) {

    for (Object keyObj : map.keySet().toArray()) {
        String keyStr = keyObj.toString();
        Field fieldObj = null;//  w  w  w .j a va  2  s  . c  om
        try {
            fieldObj = classObj.getField(prefixStr + "_" + keyStr);
        } catch (NoSuchFieldException e) {
            continue;
        }
        Object layoutObj = null;
        try {
            layoutObj = fieldObj.get(fieldObj);
        } catch (IllegalAccessException e) {
            continue;
        }
        Integer layoutIntvalue = (Integer) layoutObj;

        View selectedView = view.findViewById(layoutIntvalue);

        if (selectedView instanceof TextView) {
            TextView textView = (TextView) selectedView;
            textView.setText(String.valueOf(map.get(keyStr)));
        } else if (selectedView instanceof ImageView) {
            ImageView imageView = (ImageView) selectedView;

        }

    }

}

From source file:android.databinding.testapp.adapter.MultiArgTestAdapter.java

@BindingAdapter("android:val3")
public static void setWithOldValue(TextView view, String oldValue, String newValue) {
    view.setText(String.format("%s -> %s", oldValue, newValue));
}