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 instance 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);
如果此代码在活动的方法内,则只需将this
作为第一个参数传递即可。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.