Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an intent in a new method

So I want an intent to start an Activity that simply brings up a dialog popup box telling the user how to use the app.

I have the code:

private final View.OnClickListener btnClick = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.about_box:
            Intent i = new Intent(this, About.class);
            startActivity(i);
            break;
        }
    }
}

but the Intent is giving me the error:

The constructor Intent(new View.OnClickListener(){}, Class) is undefined

Any idea on workarounds?

Thanks.

like image 255
Sapp Avatar asked Dec 07 '22 00:12

Sapp


1 Answers

Change,

Intent i = new Intent(this, About.class);

to,

Intent i = new Intent(TheCurrentClassName.this, About.class);
like image 81
blindstuff Avatar answered Jan 02 '23 08:01

blindstuff