Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVijesh Arora
Front End Web Development Techdegree Student 34 PointsAndroid confirmation dialog when reset?
I am a beginner in Android. Creating a small counter, I have given the reset counter button when the user clicks the reset button; it should show the dialog box for the confirmation whether to really want to reset the counter or cancel it.
I have written some code, right now, it is showing the dialog box but the counter is getting reset too in background.
''' btnreset.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) {
AlertDialog.Builder myAlert = new AlertDialog.Builder(DemoActivity.this);
myAlert.setMessage("You are sure")
.setPositiveButton("Continue...", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
dialog.dismiss();
}
})
.setTitle("Welcome")
.create();
myAlert.show();
txtCount.setText(String.valueOf(0));
}
}); '''