开发者

How to move from one class to other class in android

开发者 https://www.devze.com 2023-01-07 15:27 出处:网络
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 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 othe开发者_如何学JAVAr.

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?


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);
}


make sure that activity is declared in Android.manifest.

0

精彩评论

暂无评论...
验证码 换一张
取 消