5

मुझे पता है कि इस प्रश्न के बारे में यहां कुछ प्रश्न हैं। लेकिन उनमें से कोई भी जवाब नहीं है जिसे मैं ढूंढ रहा हूं।सॉफ़्टकीबोर्ड दिखा रहा है जब बैक बटन दबाया जाता है जब संपादन बटन संपादित करें

मुझे स्क्रॉलव्यू के अंदर 7 ईटी मिल गई है। जब मैं आवेदन शुरू नहीं एट ध्यान केंद्रित क्योंकि मैं अपने समग्र लेआउट के लिए निम्न दो पंक्तियों को जोड़ दिया है है:

android:focusable="true" 
android:focusableInTouchMode="true" 

जब मैं एक एट पर क्लिक करें softkeyboard दिखाया गया है, जो मैं चाहता हूँ, तो मैं मान सेट (20 कहें)। मैं '2' दबाकर '0' दबाता हूं और फिर बैक बटन दबाता हूं। इस बिंदु पर कीबोर्ड गायब हो जाता है, लेकिन फोकस रहता है। कीबोर्ड को छुपाने के लिए बैक बटन दबाते समय भी मैं फोकस साफ़ करना चाहता हूं।

क्योंकि जब फोकस साफ़ किया जाता है तो ईटी का लेआउट सेट जैसा मैं चाहता हूं।

वे सब कुछ कोड है, जो है के बारे में है:

// Right Cable 
    RightCable = (EditText) findViewById (R.id.RightCable); 
    RightCable.setRawInputType(Configuration.KEYBOARD_12KEY); 
    RightCable.setOnFocusChangeListener(FocusChanged); 
    RightCable.addTextChangedListener(new TextWatcher() { 
     public void afterTextChanged(Editable s) { 
      if(RightCable.isFocused()){ 
       LengthRightCable  = Double.parseDouble(RightCable.getText().toString()); 
       Calculate(); 
      } 
     } 
     public void beforeTextChanged(CharSequence s, int start, int count, int after) {} 
     public void onTextChanged(CharSequence s, int start, int before, int count) { 
      if(s.toString().matches("")) { 
       RightCable.setText("0.00"); 
       Selection.setSelection(RightCable.getText(), 0, 4); 
      } 
     } 
    }); 

मैं ध्यान देने के श्रोता का उपयोग एट के इनपुट के बजाय 0.

OnFocusChangeListener FocusChanged = new OnFocusChangeListener() { 

    public void onFocusChange(View v, boolean hasFocus) { 

     EditText et = (EditText) v; 

     et.setSelection(0, et.getText().length()); 

     if(!hasFocus){ 
      String userInput = et.getText().toString(); 

      int dotPos = -1;  

      for (int i = 0; i < userInput.length(); i++) { 
       char c = userInput.charAt(i); 
       if (c == '.') { 
        dotPos = i; 
       } 
      } 

      if (dotPos == -1){ 
       et.setText(userInput + ".00"); 
      } else if(userInput.length() < 5) { 
       if (userInput.length() - dotPos == 1) { 
        et.setText(userInput + "00"); 
       } else if (userInput.length() - dotPos == 2) { 
        et.setText(userInput + "0"); 
       } 
      } 
     } 
    } 

}; 
+0

आप इस के लिए एक समाधान मिल गया है इस समस्या को हल करने के लिए इस यूआरएल का पालन का पालन करें? – PrisonMike

+0

मैं अत्यधिक जुड़ी कड़ी में Kacy जवाब अनुशंसा करते हैं: http://stackoverflow.com/questions/13975058/make-edittext-lose-focus-on-back-press –

उत्तर

0

5,00 की तरह एक नंबर करने के लिए बदलने के लिए इसके लिए आपको लेआउट फ़ाइल के पैरेंट लेआउट पर ऑन टचलिस्टर लेना होगा। टच लिस्टनर पर आपको संपादन टेक्स्ट के बाहर क्लिक करते समय कीबोर्ड को छुपाने के लिए कोड करना होगा। इस समस्या को हल करने के लिए कृपया निम्नलिखित एक्सएमएल लेआउट और जावा क्लास का पालन करें।

http://amitthaperandroidquery.blogspot.com/2011/10/remove-keyboard-after-click-outside.html

+0

आप किसी भी प्रश्न है, तो कृपया अपने ब्लॉग या टिप्पणी पर पोस्ट यह –

+0

धन्यवाद यह जानना अच्छा है, लेकिन दुर्भाग्य से वह नहीं जो मैं ढूंढ रहा था। – patrick

+0

आप चाहते हैं कि अगर मैं बैक कुंजी दबाता हूं तो कीबोर्ड अदृश्य हो जाएगा और संपादन टेक्स्ट पर ध्यान केंद्रित किया जाएगा। सही? –

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