开发者

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 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜