Skip to main content

Android Text Fields

Android Text Fields 


  • Introduction to android text fields in Hindi
  • Creating android text fields in Hindi
  • Input types of android text fields in Hindi
  • Keyboard actions of android text fields in Hindi

Introduction to Android Text Fields 

आप अपनी android application में text fields क्रिएट कर सकते है। Text fields को text boxes भी कहते है। एक text field के द्वारा आप यूज़र से input लेते है। जैसे की यूज़र का नाम और ईमेल एड्रेस। 

ज्यादातर text fields एक ही लाइन के होते है। लेकिन आप चाहे तो android में multiple lines के भी text फ़ील्ड्स क्रिएट कर सकते है। 

Text एंटर करने के लिए यूज़र text field पर क्लिक करते है। यूज़र के क्लिक करने पर typing cursor text field में शो हो जाता है। साथ ही टाइप करने के लिए keyboard भी शो हो जाता है। ये सब automatically होता है।  

आप text fields को अलग अलग तरह की input values के लिए भी configure कर सकते है। जैसे की किसी text box को आप सिर्फ email के लिए configure कर सकते है।  

Android text fields के लिए आप actions भी define कर सकते है। जो यूज़र input करने के बाद perform करता है। 


Creating Android Text Fields 

Text fields आप अपने layout में add कर सकते है। इसके लिए आप XML layout file में <EditText> element define करते है। <EditText> element के basic attributes वही है जो सब view elements define करते है -

android:id - ये attribute text field की id define करता है।  

android:layout_width - ये attribute text field की width define करता है।  

android:layout_height - इस एट्रिब्यूट के द्वारा आप text field की height define करते है।  

android:hint - इस attribute के द्वारा आप input type की hint दे सकते है।  

android:inputType - इस attribute के द्वारा आप input type डिफाइन करते है।  

android:imeOptions - इस attribute के द्वारा आप action define करते है।      


Example 



<EditText 
android:id="id for text field"
android:layout_width="width of text field"
android:layout_height="height of text field"
android:hint="hint of  input type"
android:inputType="input type"
android:imeOptions="action" /> 





Input Types of Android Text Fields 

Text fields में अलग अलग तरह की values डाली जा सकती है। जैसे की text, number, date और email address. एक text field में आप किस तरह की वैल्यू enter कर सकते है ये आप android:inputType attribute के द्वारा डिफाइन करते है।

इस attribute के लिए common input types निचे दिए जा रहे है। ये सभी input types अलग अलग keyboard शो करते है।  

text - ये input type साधारण text enter करने के लिए declare किया जाता है। ये normal text कीबोर्ड शो करता है।   

textEmailAddress - ये input type email address इनपुट करने के लिए यूज़ किया जाता है। इससे normal keyboard शो होता है @ sign के साथ।    

textUri - इस इनपुट टाइप से आप text field में URL enter कर सकते है। ये input type साधारण text keyboard शो करता है / के साथ।    

number - ये input type numbers एंटर करने के लिए यूज़ किया जाता है। और numbers का keyboard शो करता है।   

phone - इस input type को phone style keyboard के लिए यूज़ किया जाता है।  


Example


<EditText 
android:id="id for text field"
android:layout_width="width of text field"
android:layout_height="height of text field"
android:hint="hint of  input type"
android:inputType="textEmailAddress"
android:imeOptions="action" /> 



Keyboard Actions of Android Text Fields

User के information input करने के बाद action लिया जाता है। ये action क्या होता है ये आपकी एप्लीकेशन पर depend करता है। जैसे की यदि आपकी एप्लीकेशन searching की service provide करती है तो action search हो सकता है और यदि आपकी एप्लीकेशन messaging की service provide करती है तो ये action send हो सकता है।

किस तरह का action आप लेना चाहते है ये आपकी application पर निर्भर होता है। यदि आप कोई action डिफाइन नहीं करते है तो next का option निचे right hand side corner में शो होता है। नहीं तो जो action आप डिफाइन करते है वो शो होता है।

Keyboard action आप android:imeOptions attribute के द्वारा डिफाइन कर सकते है।

Example


<EditText 
android:id="id for text field"
android:layout_width="width of text field"
android:layout_height="height of text field"
android:hint="hint of  input type"
android:inputType="textEmailAddress"
android:imeOptions="actionSend" /> 

Comments

Popular posts from this blog

Android Services

Android Services Introduction to  android services in Hindi  Declaring  services in Hindi Creating a  android service in Hindi Introduction to Android Services इससे पहले की आप जाने की service क्या होती है आइये जानते है की service क्या नहीं होती है - एक service separate प्रोसेस नहीं होती है। ये आपकी एप्लीकेशन का ही पार्ट होती है।  एक service thread नहीं होती है।  आइये अब देखते है service क्या होती है - Service एक facility होती है जिससे आप android system को बता सकते है की आप कोई काम background में करते रहना चाहते है।  Service एक facility होती है जिससे एक एप्लीकेशन अपनी कुछ functionality दूसरी applications को expose कर सकती है।    हर service क्लास का <service> declaration AndroidManifest.xml file में होना चाहिए। Services को आप context.startService() और context.bindService() मेथड्स से स्टार्ट कर सकते है।            जब service component क्रिएट होता है तो android syst...

Android Activity

Android Activity Activity life cycle in Hindi Starting an  android activity in Hindi Creating a new activity in Hindi Destroying an  android activity in Hindi Introduction to Activity आप की application में एक से ज्यादा activity हो सकती है। जब आप इन activities के through navigate करते है, यानि एक activity से दूसरी activity में जाते है तो activity अपनी life cycle की different stages में जाती है। उदाहरण के लिए जब आपकी activity start होती है तो ये foreground में होती है और user का पूरा focus इस पर होता है। इस process के दौरान  android  system कुछ life cycle methods को call करता है। यदि user कोई दूसरी activity start करता है तो android system उस activity के life cycle methods को call करता है और आपकी पहले वाली activity background में चली जाती है। life cycle methods में आप decide कर सकते है की जब user जाता है या वापस आता है तो आपकी activity कैसे behave करेगी।  उदाहरण के लिए यदि आप एक वीडियो player बना रहे है तो जब user किसी दूसरी activity पर जाये तो...

Android Spinners

Android Spinners  Introduction to  android spinners in Hindi Defining  android spinners in Hindi Creating spinner items array in Hindi Responding to spinner selections in Hindi    Introduction to Android Spinners Android spinners आपकी एप्लीकेशन में एक drop down menu होती है। इस drop down menu में बहुत से items होते है जिन्हे user choices कहते है। जब user spinner पर क्लिक करता है तो ये items शो होते है। यूज़र अपने लिए appropriate choice choose करता है। By default spinner में सबसे top वाला element शो होता है। Spinners को XML layout file में क्रिएट किया जाता है। और items की लिस्ट string resource file में क्रिएट की जाती है। जिसमे आप एक string array क्रिएट करते है।  Spinner और items को जोड़ने के लिए एक array adapter क्रिएट किया जाता है। इसके बाद selection events को respond करने के लिए OnItemSelectedListener interface को  इम्प्लीमेंट किया जाता है।  Defining Android Spinners Android spinners को आप XML l...