<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_settings"
android:title="Settings"
android:icon="@drawable/ic_settings"
android:showAsAction="always"/>
</menu>
Introduction to Menus and types of menus in hindi
Introduction to Menus
- Menu Android Apps में एक Navigation Component है, जो Users को Options और Actions Select करने की सुविधा देता है।
- Android में मुख्य रूप से तीन प्रकार के Menus होते हैं: Options Menu, Context Menu, और Popup Menu।
- Options Menu Screen के ऊपर दाईं ओर Three-dot Menu के रूप में Show होता है और Primary Actions के लिए Use किया जाता है।
- Context Menu किसी Specific Item (जैसे कि ListView या Text) को Long Press करने पर Open होता है और Item-Specific Actions Provide करता है।
- Popup Menu एक छोटा Floating Menu होता है, जो Button Click करने पर Open होता है और Temporary Options Provide करता है।
- Menu को XML File में Define किया जाता है और onCreateOptionsMenu() Method के द्वारा Activity में Load किया जाता है।
- Menu Items में Icons, Titles, और Submenus Add किए जा सकते हैं, जिससे User Experience और बेहतर हो जाता है।
- Menu में Items को Handle करने के लिए onOptionsItemSelected() Method का उपयोग किया जाता है।
- Menus का उपयोग Settings, Search, Logout, और अन्य Common Actions को Simplify करने के लिए किया जाता है।
- Menus Android Apps को Organized और User-Friendly बनाते हैं, जिससे Navigation आसान हो जाता है।
Types of Menus (Option menu, Context menu) in hindi
1. Options Menu:
- यह Primary Menu होता है, जो Three-Dot (⋮) Icon के रूप में Screen के ऊपर दाईं ओर Show होता है।
- इसमें Settings, Search, Logout जैसी Common Actions होती हैं।
- इसे onCreateOptionsMenu() Method के द्वारा Create किया जाता है।
- XML में इसे Define किया जाता है और Activity में Inflate किया जाता है।
- Example:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
2. Context Menu
- यह Long Press (Click & Hold) करने पर Open होता है और Specific Items (जैसे ListView या ImageView) के लिए होता है।
- इसे registerForContextMenu(View) Method से Register करना पड़ता है।
- इसे onCreateContextMenu() Method में Define किया जाता है।
- Example:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Select an Action");
menu.add(0, v.getId(), 0, "Edit");
menu.add(0, v.getId(), 0, "Delete");
}
Options Menu पूरी Screen के लिए होता है, जबकि Context Menu सिर्फ एक Specific Item के लिए Use किया जाता है।
Request
अगर आपको यह article useful या interesting लगा हो, तो please इसे अपने dosto aur family ke साथ जरूर share करें। आपका एक छोटा सा कदम हमें और अच्छा content बनाने के लिए motivate करता है। Thank you!
ध्यान दें कि इस page पर आपको कुछ ads भी देखने को मिल सकते हैं। इसके लिए हम आपसे माफी चाहते हैं। हम इस content को तैयार करने में काफी मेहनत और time लगाते हैं, ताकि आपको valuable जानकारी मिल सके। इन्हीं ads की मदद से हम ये काम continue कर पाते हैं।
आपके support और understanding के लिए दिल से धन्यवाद।
Ad
Ad