add Navigation Rule to Activity via on click listener - Android Activity

Android examples for Activity:Activity Action

Description

add Navigation Rule to Activity via on click listener

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

public class Main {
    public static void addNavigationRule(int idView, final Activity from,
            final Class to) {

        View view = from.findViewById(idView);
        view.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Intent intent = new Intent();
                intent.setClass(from, to);

                from.startActivity(intent);

            }/*from w  w  w  .  j  a va 2  s. c  o m*/
        });

    }
}

Related Tutorials