What is the error (this) in the code
button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(this) .title(R.string.app_name) .show(); } }); What is the error (this) in the code
button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(this) .title(R.string.app_name) .show(); } }); MaterialDialog Builder takes Context for input .
You have this - a link to the anonymous class OnClickListener .
You can for example:
new MaterialDialog.Builder(НазваниеВашегоActivity.this){...} Context , obviously. - D-sidenew MaterialDialog.Builder(НазваниеВашегоActivity.this){...} YourActivity.this new MaterialDialog.Builder(НазваниеВашегоActivity.this){...} - Suvitruf ♦Source: https://ru.stackoverflow.com/questions/475660/
All Articles
Context, and an anonymous class based onView.OnClickListener. - zRrr