Reputation: 13
I want to put the Activity class inside my custom view like this
public class AppLauncher extends LinearLayout
{
// My custom view
public class Settings extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.app_launcher_settings);
}
}
}
and I started the activity with
Intent setting = new Intent(mContext, AppLauncher.Settings.class);
mContext.startActivity(setting);
but my app crash with error
java.lang.Class<in.blackant.systemui.widget.AppLauncher$Settings> has no zero argument constructor
Upvotes: 0
Views: 46
Reputation: 1006819
I want to put the Activity class inside my custom view like this
That is extremely strange.
but my app crash with error
java.lang.Class<in.blackant.systemui.widget.AppLauncher$Settings>
has no zero argument constructor
That is because Settings
is an inner class. Only AppLauncher
can create an instance of it. As a result, the framework cannot create an instance of it.
If you really wish to keep this current structure, you would need to make Settings
static:
public static class Settings extends Activity
Upvotes: 2