Related Topics

What is Mobile Computing in Hindi?

Brief history of mobile technology in Hindi

Mobile Phone Generations in Hindi

The Mobile Ecosystem in Hindi

Types of Mobile Applications in Hindi

Mobile Information Architecture in Hindi

Android Versions in Hindi

Features of Android in Hindi

Android Architecture in Hindi

Installing Android SDK Tools in Hindi

Configuring Android in Eclipse IDE in Hindi

Android Development Tools (ADT) in Hindi

Creating Android Virtual Devices (AVD) in Hindi

Creating First Android Application in Hindi

Anatomy of Android Application in Hindi

Deploying Android App on USB Connected Android Device in Hindi

Android Application Components in Hindi

Android Activity Life Cycle in Hindi

Android Activities in Hindi

Exploring Intent Objects in Hindi

Linking Activities Using Intents in Hindi

Android Fragment Lifecycle in Hindi

Android UI Layouts in Hindi

Adapting to Display Orientation in Android in Hindi

Action Bar in Android in Hindi

Android Alarm Manager in Hindi

Displaying Analog & Digital Clocks in Android in Hindi

Event Handling in Android in Hindi

Android Menus in Hindi

Data Storage Options in Android in Hindi

External Storage in Android in Hindi

Content Providers in Android in Hindi

Views in Android in Hindi

Button in Android in Hindi

Toast in Android in Hindi

ToggleButton in Android in Hindi

CheckBox in Android in Hindi

RadioButton in Android in Hindi

Spinner in Android in Hindi

WebView in Android in Hindi

EditText in Android in Hindi

DatePicker in Android in Hindi

TimePicker in Android in Hindi

ListView in Android in Hindi

ProgressBar in Android in Hindi

Handling UI Events in Android in Hindi

ListFragment in Android in Hindi

DialogFragment in Android in Hindi

Context in Android in Hindi

Popup in Android in Hindi

ImageView in Android in Hindi

ImageSwitcher in Android in Hindi

AlarmManager in Android in Hindi

SMS in Android in Hindi

E-mail in Android in Hindi

MediaPlayer in Android in Hindi

Using Camera in Android in Hindi

Video Recording in Android in Hindi

Telephony Manager in Android in Hindi

Android SQLite Database in Hindi

SQLite database operations in Hindi

Publishing Android Applications in Hindi

Deploying APK Files in Android in Hindi

Related Subjects

AlertDialog in Android in Hindi

RGPV University / DIPLOMA_CSE / MOBILE COMPUTING

AlertDialog in Android in Hindi

What is AlertDialog in Android in Hindi

Android में AlertDialog एक ऐसा pop-up window होता है जो user को कोई जानकारी देने या user से confirmation लेने के लिए उपयोग किया जाता है। जब हमें user से कोई निर्णय लेना होता है जैसे कि "Yes" या "No", या कोई चेतावनी (warning) दिखानी होती है, तब AlertDialog का उपयोग किया जाता है। यह Dialog स्क्रीन के ऊपर दिखाई देता है और user के interaction का इंतजार करता है।

Use of AlertDialog in Hindi

  • जब user से confirmation लेनी हो जैसे "Are you sure you want to delete this?"
  • जब किसी action को करने से पहले चेतावनी (warning) देनी हो
  • जब कोई जरूरी जानकारी user को दिखानी हो
  • जब multiple options दिखाने हों जैसे "Choose from list"

Types of Buttons in AlertDialog in Hindi

  • Positive Button – यह "OK", "Yes" जैसे सकारात्मक action के लिए होता है।
  • Negative Button – यह "Cancel", "No" जैसे नकारात्मक action के लिए होता है।
  • Neutral Button – यह ऐसा button होता है जो किसी भी direction में नहीं जाता जैसे "Remind Me Later"

Features of AlertDialog in Android in Hindi

  • Custom Title और Message सेट कर सकते हैं।
  • Buttons जैसे Positive, Negative और Neutral जोड़ सकते हैं।
  • Custom layout का उपयोग करके अपने UI को personalize कर सकते हैं।
  • List या Multi-Choice Items भी AlertDialog में दिखाए जा सकते हैं।
  • AlertDialog user को कोई भी action लेने से पहले रोकता है (modal होता है)।

Creating a Simple AlertDialog in Android in Hindi

अब हम एक साधारण AlertDialog बनाना सीखते हैं जो user से confirmation लेता है:

// Java में AlertDialog बनाने का code AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("Delete Item"); builder.setMessage("क्या आप वाकई इस item को delete करना चाहते हैं?"); builder.setPositiveButton("हाँ", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // delete action यहां होगा } }); builder.setNegativeButton("नहीं", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // dialog को बंद कर देता है } }); AlertDialog dialog = builder.create(); dialog.show();

ऊपर दिए गए code में AlertDialog.Builder class का उपयोग करके एक dialog बनाया गया है।
setTitle() और setMessage() methods से dialog का title और message सेट किया जाता है।
setPositiveButton() और setNegativeButton() से दो विकल्प दिए गए हैं जिनमें click listener सेट किया गया है।
dialog.show() से dialog को स्क्रीन पर दिखाया जाता है।

Custom Layout AlertDialog in Hindi

कभी-कभी हम AlertDialog के अंदर एक custom layout भी उपयोग करना चाहते हैं जैसे form या कोई complex design। इसके लिए पहले layout XML file बनानी होती है:

// custom_dialog.xml (layout file) // Java में custom AlertDialog LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.custom_dialog, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(dialogView); builder.setTitle("Custom AlertDialog"); builder.setPositiveButton("सबमिट करें", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { EditText input = dialogView.findViewById(R.id.inputField); String value = input.getText().toString(); // value का उपयोग करें } }); builder.setNegativeButton("रद्द करें", null); AlertDialog dialog = builder.create(); dialog.show();

इस तरीके से हम custom input या कोई भी user interaction AlertDialog में शामिल कर सकते हैं। यह approach तब उपयोगी होती है जब user से कोई जानकारी लेनी हो।

FAQs

AlertDialog Android का एक component होता है जो एक छोटा pop-up window दिखाता है। इसका उपयोग user को सूचना देने या उनसे confirmation लेने के लिए किया जाता है।
AlertDialog में तीन प्रकार के buttons हो सकते हैं – Positive Button, Negative Button और Neutral Button। ये buttons user को विभिन्न प्रकार के options प्रदान करते हैं।
हां, हम AlertDialog में custom layout का उपयोग कर सकते हैं। इसके लिए एक अलग XML layout बनाकर उसे AlertDialog में setView() method द्वारा जोड़ा जाता है।
हां, AlertDialog डिफ़ॉल्ट रूप से cancelable होता है, यानी user बाहर click करके या back button दबाकर इसे बंद कर सकता है। इसे non-cancelable भी बनाया जा सकता है।
AlertDialog को दिखाने के लिए show() method का उपयोग किया जाता है। यह dialog को स्क्रीन पर प्रकट करता है।
हां, हम AlertDialog में setTitle() और setMessage() methods का उपयोग करके title और message को आसानी से सेट कर सकते हैं।

Please Give Us Feedback