AlertDialogs have a text that informs the user and also contains several buttons that are performed according to the desired operation and the text in which it is written. AlertDialogs can be used to display warnings, delete notifications, inform users. AlertDialogs can hold up to three buttons and users can perform the desired operation according to the text that is inserted in it. If you want to know about AlertDialogs and create a project or work with AlertDialog, we suggest you follow this tutorial.
alertdialog. builder example
1- Create a new project in Android Studio called AlertDialog (alertdialog android studio). Of course, it should be noted that the name of the project is arbitrary and you can choose another name for it. The chosen name for this project in this tutorial is AlertDialog.2- After creating the project, it is better to create an Empty Activity.3- In this project, we need the appcompat-v7 library in order to be able to perform our desired operations. It is better to add it to the project as well.4- In the activity, we create an example of AlertDialog.Builder and of course we choose the desired name for it. For example, the name of choice in this project is alertBuilder.5- Then we have to do the following inside the onCreate method.
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os. Bundle;
public class MainActivity extends AppCompatActivity {
AlertDialog.Builder alertBuilder;
@Override
protected void onCreate (Bundle savedInstanceState) {
super. onCreate (savedInstanceState);
setContentView (R. layout. activity_main);
alertBuilder = new AlertDialog.Builder (this);
}
}
In the code above, AlertDialog.Builder currently receives a parameter, which is also Context.
Note:
Be sure to select AlertDialog, which is related to the support library.6- Create a simple AlertDialog.7- Then we complete it as follows.
alertdialog example
Read more on:https://www.dotnek.com/Blog/Apps/what-is-alertdialog-in-android-and-in-what-ca
link:https://dotnek.mystrikingly.com/
Related link:SEO
:: برچسبها:
dotnek ,
seo ,
site ,
:: بازدید از این مطلب : 93
|
امتیاز مطلب : 0
|
تعداد امتیازدهندگان : 0
|
مجموع امتیاز : 0