Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Method;

import android.app.Activity;

import android.view.View;

public class Main {
    public static void putTextToViewById(Activity a, int id, int text) {

        View view = a.findViewById(id);

        Method m = null;

        try {
            m = view.getClass().getMethod("setText", new Class[] { Integer.TYPE });
        } catch (NoSuchMethodException e) {

        }
        if (m != null) {
            try {
                m.invoke(view, text);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
}