开发者

how to start a new activity from anther activity ... in android?

i want to start a new activity from ab activity that (extends from Linearlayout) .. but this code is not right

Intent i = new Intent(SearchResultForm.this, MainActivity.class);
startActivity(i);

... ...

public class SearchResultForm extends LinearLayout{ ...

and i get this error ..

No enclosing i开发者_开发知识库nstance of the type SearchResultForm is accessible in scope

how can i do it ?


Just guessing since I can't see the rest of your code, but try:

Intent i = new Intent(this, MainActivity.class);
startActivity(i);


Try this:

Intent i = new Intent(this, MainActivity.getPackageName());
startActivity(i);


If this code is inside an activity's method, just pass this as the first parameter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜