1

I want to shift my cursor from one edit text to another which are placed vertically.

But i want it to shift on a button click i.e., when i click on the button it should directly move onto the next edit text and even it should perform the desired task.

I am making use of "holder" to hold the data present in the list. any suggestions...????

code is:

holder.txtSrc = (EditText) convertView .findViewById(R.id.txt_src_word);
holder.btnTranslate .setOnClickListener(new View.OnClickListener() { 
    public void onClick(View v) { 
        // translate text 
        txtSrc.requestFocus(); 
        Button bt = (Button) v; 
        pos = (Integer) bt.getTag();
        translate(); } });
    }
}
Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138
shubham0703
  • 59
  • 2
  • 12
  • Please show your efforts before asking for solutions, thanks. – ᗩИᎠЯƎᗩ Mar 25 '14 at 11:24
  • My issue is for example: EditText txtSrc; -------- holder.txtSrc = (EditText) convertView .findViewById(R.id.txt_src_word); --- holder.btnTranslate .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // translate text txtSrc.requestFocus(); Button bt = (Button) v; pos = (Integer) bt.getTag(); translate(); } }); it shows error in "txtSrc".requestFocus(); – shubham0703 Mar 25 '14 at 11:30
  • Possible duplicate of [Android XML - moving between EditText fields](https://stackoverflow.com/questions/16223852/android-xml-moving-between-edittext-fields) – Ricardo A. May 03 '19 at 12:14

2 Answers2

1

In edittext thier is an android:imeOptions="actionNext" use that

jyomin
  • 1,957
  • 2
  • 11
  • 27
  • My issue is for example: EditText txtSrc; -------- holder.txtSrc = (EditText) convertView .findViewById(R.id.txt_src_word); --- holder.btnTranslate .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // translate text txtSrc.requestFocus(); Button bt = (Button) v; pos = (Integer) bt.getTag(); translate(); } }); it shows error in "txtSrc".requestFocus(); – shubham0703 Mar 25 '14 at 11:29
1

Simply use editText.requestFocus(); on button click

OR

There is another way to do it simply by using the following attribute

android:imeOptions="actionNext"

For example :

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

Thanks,

Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138
  • i have gone through every post related to this topic but none of them made me resolve my issue... My issue is for example: EditText txtSrc; -------- holder.txtSrc = (EditText) convertView .findViewById(R.id.txt_src_word); --- holder.btnTranslate .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // translate text txtSrc.requestFocus(); Button bt = (Button) v; pos = (Integer) bt.getTag(); translate(); } }); – shubham0703 Mar 25 '14 at 11:23
  • here you need to use holder.txtSrc.requestFocus(); – Shailendra Madda Mar 25 '14 at 11:33
  • now it gives error in "holder".txtSrc.requestFocus(); – shubham0703 Mar 25 '14 at 11:35