Rakesh
Rakesh

Reputation: 15047

How to move from one class to other class in android

I want to know how to move from one class to other class in android.
I have one main class i.e Addition.java(Main Activity) and i created other subactivity(Form.java). I want to how to make my move from one class(ie.Activity)to other.

I tried this,but not working out,just trying to figure out

Intent intent = new Intent();
intent.setClass(this.getParent(),Form.class);
startActivity(intent);

here Form.class is the subactivity, this.getParent I hope it represents main activity. And I created one activity in manifest.xml file and named it as .Form

Am i working right?

Upvotes: 2

Views: 3558

Answers (2)

Vishal Khakhkhar
Vishal Khakhkhar

Reputation: 2116

make sure that activity is declared in Android.manifest.

Upvotes: 1

Paresh Mayani
Paresh Mayani

Reputation: 128428

The below code works perfectly.
Try it:

@Override
public void onClick(View v) 
{
Intent intent = new Intent();
intent.setClass(v.getContext(),Form.class);
startActivity(intent);
}

Upvotes: 1

Related Questions