Find View by view id - Android android.app

Android examples for android.app:Activity

Description

Find View by view id

Demo Code

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class Main{

    @SuppressWarnings("unchecked")
    public static <T extends View> T Find(Activity activity, int id) {
        return (T) activity.findViewById(id);
    }//from ww  w  .j a  v a2s.c o  m

}

Related Tutorials