I'm new to Android Studio. I have tried Speech to Text with one edit text and it's working fine. But I want to apply Speech to Text for two edit texts with one button. Can anyone help me, please? I have tried from other resources but it's not working.

```
 <EditText
        android:id="@+id/txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="phone"
        android:hint="phone"
        android:ems="10" />

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="text"
        android:ems="10"
        android:inputType="text" />

    <Button
        android:id="@+id/button3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button" />

```

Here is the java code i want to apply speech to text through single button and two edit text .when the button is clicked it should roll down to next edit text and take the input

```
public class MainActivity extends AppCompatActivity {
        EditText tv1;
        EditText tv2;
        Button btn;
        private static final int REQUEST_CODE_SPEECH_INPUT = 1000;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            tv1 = findViewById(R.id.txt);
            tv2=findViewById(R.id.editText);
            btn = findViewById(R.id.button3);
            btn.setOnClickListener(new View.OnClickListener() {
                @Override 
                public void onClick(View v) {
                    speak();
                }

                private void speak() { 
                    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
                    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
                    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "say something");

                    try {
                        startActivityForResult(intent, REQUEST_CODE_SPEECH_INPUT);

                    } catch (Exception e) {
                        ///Toast.makeText(this,"",Toast.LENGTH_SHORT).show();

                    }
                }

            });
        }
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);

            switch (requestCode) {
                case REQUEST_CODE_SPEECH_INPUT: {
                    if (resultCode == RESULT_OK && null != data) {

                        ArrayList<String> result = data
                                .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                        tv1.setText(result.get(0));
                    }
                    break;
                }

            }
        }
    }

```