Im trying to link up the array[1] to launch an activity but its showing me an error on this line
Intent i1 = new Intent(this, Difficulty.class); If any one sees where im going wrong help me please
the error reads “The constructor Intent(new DialogInterface.OnClickListener(){}, Class) is undefined”
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if ("Green".equals(items[1]))
{Intent intent = new Intent();
Intent i1 = new Intent(this, Diff.class);
startActivity(i1);;}
}
}).show();
AlertDialog alert = builder.create();
Change
to
and replace “TheNameOfYourActivity” with the name of the activity that this is taking place inside of.