Hello, I'm the developer of Android.
class anonymous class derived from clicklistener must other be defined or implemented abstract method 'OnClick(View)' int 'OnClickListener'
is struggling.
Code is
public class MainActivity extends AppCompatActivity {
privateString[] items = {"mango juice", "tomato juice", "grape juice"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button listButton = (Button) findeViewById(R.id.listButton);
listButton.setOnClickListener(new View.OnClickListener() {
@Override
public void Onclick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle ("list");
bulider.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(getApplicationContext(), items[i], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
});
}
}
the eleventh line from
listButton.setOnClickListener(new View.OnClickListener() {
newView of .OnClickListener()
displays the error.
I think OnClick
is the problem, but I don't know how to solve it.
Na Dongbin, this is an error that occurred in the third lecture on Android.
I'm looking for someone to help me desperately.
android java
Isn't it onClick (View v), not Onclick (View v)?
© 2024 OneMinuteCode. All rights reserved.