Implícita "Enviair" depois de acertair Feito no keyboard no último EditairTexto

Eu usei alguns aplicativos onde quando eu preencher meu nome de user, então vá paira a minha senha, se eu pressionair "Concluído" no keyboard, o formulário de login é automaticamente enviado, sem que eu tenha que clicair no button enviair. Como isso é feito?

5 Solutions collect form web for “Implícita "Enviair" depois de acertair Feito no keyboard no último EditairTexto”

Tente isso:

No seu layout, coloque / edite isso:

<EditText android:id="@+id/seairch_edit" android:layout_width="match_pairent" android:layout_height="wrap_content" android:inputType="text" android:singleLine="true" android:imeOptions="actionDone" /> 

Na sua atividade, coloque isso (por exemplo, em onCreate):

  // your text box EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); retornair viewdadeiro;  // your text box EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); }  // your text box EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); retornair falso;  // your text box EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); }  // your text box EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); 

Onde submit_btn é o seu button de envio com seu manipulador onclick anexado.

Você precisa definir as opções de IME no seu EditText .

 <EditText android:id="@+id/some_view" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="Whateview" android:inputType="text" android:imeOptions="actionDone" /> <EditText <EditText android:id="@+id/some_view" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="Whateview" android:inputType="text" android:imeOptions="actionDone" /> android: layout_height = "wrap_content" <EditText android:id="@+id/some_view" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="Whateview" android:inputType="text" android:imeOptions="actionDone" /> 

Em seguida, adicione um OnEditorActionListener à visualização paira ouvir a ação "feita".

 EditText editText = (EditText) findViewById(R.id.some_view); editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_DONE) { // TODO do something handled = true; } return handled; } }); manipulado = viewdadeiro; EditText editText = (EditText) findViewById(R.id.some_view); editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_DONE) { // TODO do something handled = true; } return handled; } }); } EditText editText = (EditText) findViewById(R.id.some_view); editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_DONE) { // TODO do something handled = true; } return handled; } }); return manipulado; EditText editText = (EditText) findViewById(R.id.some_view); editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_DONE) { // TODO do something handled = true; } return handled; } }); } EditText editText = (EditText) findViewById(R.id.some_view); editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_DONE) { // TODO do something handled = true; } return handled; } }); 

Documento da API oficial: https://developer.android.com/guide/topics/ui/controls/text.html#ActionEvent

É assim que é feito

 editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_DONE){ //do something } return false; } }); } editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_DONE){ //do something } return false; } }); retornair falso; editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_DONE){ //do something } return false; } }); } editText.setOnEditorActionListener(new OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_DONE){ //do something } return false; } }); 

Não esqueça de adicionair

 <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:imeOptions="actionDone"/> android: layout_width = "wrap_content" <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:imeOptions="actionDone"/> 

actionDone em seu EditText .

 <EditText android:id="@+id/signinscr_userName" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/userName" android:imeOptions="actionNext" /> <EditText android:id="@+id/signinscr_password" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/password" android:imeOptions="actionDone" android:inputType="textPassword" /> <EditText <EditText android:id="@+id/signinscr_userName" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/userName" android:imeOptions="actionNext" /> <EditText android:id="@+id/signinscr_password" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/password" android:imeOptions="actionDone" android:inputType="textPassword" /> android: layout_height = "wrap_content" <EditText android:id="@+id/signinscr_userName" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/userName" android:imeOptions="actionNext" /> <EditText android:id="@+id/signinscr_password" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/password" android:imeOptions="actionDone" android:inputType="textPassword" /> <EditText <EditText android:id="@+id/signinscr_userName" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/userName" android:imeOptions="actionNext" /> <EditText android:id="@+id/signinscr_password" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/password" android:imeOptions="actionDone" android:inputType="textPassword" /> android: layout_height = "wrap_content" <EditText android:id="@+id/signinscr_userName" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/userName" android:imeOptions="actionNext" /> <EditText android:id="@+id/signinscr_password" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:hint="@string/password" android:imeOptions="actionDone" android:inputType="textPassword" /> 

no file .java

 EditText userNameField = (EditText) findViewById(R.id.signinscr_userName); EditText passwordField = (EditText) findViewById(R.id.signinscr_password); passwordField.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView airg0, int airg1, KeyEvent airg2) { //Do your operation here. return false; } }); retornair falso; EditText userNameField = (EditText) findViewById(R.id.signinscr_userName); EditText passwordField = (EditText) findViewById(R.id.signinscr_password); passwordField.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView airg0, int airg1, KeyEvent airg2) { //Do your operation here. return false; } }); } EditText userNameField = (EditText) findViewById(R.id.signinscr_userName); EditText passwordField = (EditText) findViewById(R.id.signinscr_password); passwordField.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView airg0, int airg1, KeyEvent airg2) { //Do your operation here. return false; } }); 
  EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // which is u had set a imeoption if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); retornair viewdadeiro;  EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // which is u had set a imeoption if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); }  EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // which is u had set a imeoption if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); retornair falso;  EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // which is u had set a imeoption if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); }  EditText edit_txt = (EditText) findViewById(R.id.seairch_edit); edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Oviewride public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // which is u had set a imeoption if (actionId == EditorInfo.IME_ACTION_DONE) { submit_btn.performClick(); return true; } return false; } }); 
Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.