2012-09-14 8 views
6

मैं कर्सर को एडिटटेक्स्ट 1 से दूसरे एडिटटेक्स्ट 2 में ले जाना चाहता हूं। मैं पहले से संपादित करने के लिए ध्यान केंद्रित कर चुका था टेक्स्ट 1 लेकिन कर्सर को संपादित करने के लिए कैसे करें पाठ 2।एंड्रॉइड क्षेत्र में किसी भी अक्षर पर क्लिक करते समय कर्सर को एक संपादन टेक्स्ट से दूसरे में ले जाएं?

+0

शायद जोड़ने के एक [TextWatcher] (http://developer.android.com/reference/android/text/TextWatcher.html) अपने 'EditText1' पर – Aprian

+0

मेरा उत्तर यहां देखें: http: //stackoverflow.com/questions/9003166/android-keyboard-next-button-issue-on-edittext/9003285#9003285 इससे मदद मिल सकती है। – Hiral

+0

आपकी मदद के लिए यू (अप्रैलियन और हिरल) दोनों का धन्यवाद। अब यह काम कर रहा है, TextWatcher मेरी मदद ..... – anoop

उत्तर

0

अपने edittext1 क्लिक कोड में सेट गुण ...

EditText2.requestFocus();

0
EditText editText1 = (EditText)findViewById(R.id.editText1); 
    EditText editText2 = (EditText)findViewById(R.id.editText2); 


editText1.setOnKeyListener(new OnKeyListener() { 

public boolean onKey(View v, int keyCode, KeyEvent event) { 
     // If the event is a key-down event on the "enter" button 
     if ((event.getAction() == KeyEvent.ACTION_DOWN) && 
      (keyCode == KeyEvent.KEYCODE_ENTER)) 
     { 
      // Perform action on Enter key press 
      editText1.clearFocus(); 
      editText2.requestFocus(); 
      return true; 
     } 
     return false; 
} 
}); 
10

अंत में मैं इस सवाल का जवाब मिल गया:

editText1.addTextChangedListener(new TextWatcher() { 

       public void onTextChanged(CharSequence s, int start, int before, 
         int count) { 
        Integer textlength1 = editText1.getText().length(); 

        if (textlength1 >= 1) { 
         editText2.requestFocus(); 
        } 
       } 

       @Override 
       public void afterTextChanged(Editable s) { 
        // TODO Auto-generated method stub 
       } 

       @Override 
       public void beforeTextChanged(CharSequence s, int start, int count, 
         int after) { 
        // TODO Auto-generated method stub 
       } 
      }); 

      editText2.addTextChangedListener(new TextWatcher() { 

       public void onTextChanged(CharSequence s, int start, int before, 
         int count) { 
        Integer textlength2 = editText1.getText().length(); 

        if (textlength2 >= 1) { 
         editText3.requestFocus(); 

        } 
       } 

       @Override 
       public void afterTextChanged(Editable s) { 
        // TODO Auto-generated method stub 
       } 

       @Override 
       public void beforeTextChanged(CharSequence s, int start, int count, 
         int after) { 
        // TODO Auto-generated method stub 

       } 
      }); 
2

मैं अपने जवाब को समझ सकता हूँ,

लेकिन यह करने के लिए एक और अच्छा तरीका है बस निम्न विशेषता

का उपयोग करके होती है

एंड्रॉइड: imeOptions = "actionNext"

उदाहरण:

<EditText 
android:hint="@string/hint_user_name" 
android:id="@+id/et_user_name" 
android:maxLines="2" 
style="@style/EditText_Login" 
android:imeOptions="actionNext" 
/> 

धन्यवाद,