2010-07-18 15 views
48

मेरे पास एक संपादन टेक्स्ट है जिसे निम्नानुसार परिभाषित किया गया है।एंड्रॉइड: टेक्स्ट गो बटन संपादित करें

<EditText 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:maxLines="1" 
android:inputType="text" 
android:hint="@string/field_text" 
android:id="@+id/field" 
/> 

मैं इतना है कि जब कोई ऑनस्क्रीन कीबोर्ड पर हो गया/जाएँ बटन पर क्लिक करता है एक बटन क्लिक किया जाता है एक कस्टम आदेश सेट करने के लिए या सिर्फ तरीकों कि बटन द्वारा चलाए जा रहे हैं चलाने चाहते हैं। मुझे लगता है कि इसका आईम विकल्प के साथ कुछ करना है, लेकिन मैं यह समझने में सक्षम हूं कि वे कैसे काम करते हैं। किसी भी सहायता के लिए अग्रिम रूप से धन्यवाद!

उत्तर

117

आप एंड्रॉयड का एक संयोजन चाहते हैं।

+1

बस इस उत्तर पर फ़ॉलो करना चाहते हैं और उल्लेख करते हैं कि यह आवश्यक रूप से सभी उपकरणों पर काम नहीं करता है। उदाहरण के लिए, मैंने अपने ऐप में OnEditorActionListener का उपयोग करने के लिए अपना ऑनके लिस्टनर कोड बदल दिया और अचानक मेरे एचटीसी एवो ने कार्रवाई करने से रोक दिया। अधिक जानकारी के लिए इसे देखें: http://stackoverflow.com/questions/3886677/imeoptions-on-htc-devices – Dan

+0

अच्छा उदाहरण .... – AndroidDanger

+0

लेकिन इस उदाहरण का उपयोग करके आप multiline editext नहीं बना सकते हैं। चैट टेक्स्ट की तरह, इस यू में जोड़ा गया पाठ Wrodwrap automaticaly नहीं है। –

0

घटनाओं के लिए प्रतिक्रिया करने के लिए एक श्रोता सेट करने के लिए setImeActionLabel विधि (या imeActionLabel और imeActionId विशेषताएँ) पर एक नज़र और setOnEditorActionListener लो। तदनुसार imeOptions और setOnEditorActionListener

<EditText android:id="@+id/some_edittext" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:imeOptions="actionSend"> 
</EditText> 


some_edittext.setOnEditorActionListener(new OnEditorActionListener() { 
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { 
     if (actionId == EditorInfo.IME_ACTION_SEND) { 
      some_button.performClick(); 
      return true; 
     } 
     return false; 
    } 
}); 

जाहिर है आप कार्रवाई करने के लिए आप चाहते हैं actionSend बदलना चाहिए, और अद्यतन IME_ACTION_SEND:

संबंधित मुद्दे