How to navigate between FRAGMENT without losing the information you have in the EditText fields?

I have several FRAGMENTs that are displayed in an activity one by one, in each FRAGMENT I have a form with EditText fields. The problem I have is that when I fill the EditText fields of one FRAGMENT and go to the next FRAGMENT and I return, the data from the previous FRAGMENT in the EditText disappears and is blank, like when the application starts.

How can I navigate between the FRAGMENTS without losing the ones in the EditText?


mysql – Execute action from editText by pressing enter without using clicklistener and keeping focus on editText

I would like to remove the query button, and when giving enter in the editText the query is executed without the need for the button,
and that the focus stays on the editText to be able to continue putting barcodes and just press enter to see it

The query is currently running with set on click listener, but I have to be clicking the button and the focus stays on the button, so I have to click the editText again to insert another code, and I would like it to be executed with a barcode scanner, so I would like the cursor to always stay on the editText and the query to be executed with the enter key after putting the barcode

public class MainActivity extends AppCompatActivity {

    EditText prod;
    TextView res;
    Button bsq;

    protected void onCreate(Bundle savedInstanceState) {

        prod=(EditText) findViewById(;
        res=(TextView)  findViewById(;
        bsq=(Button)    findViewById(;

     bsq.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {



    public Connection conexionBD(){
        Connection  cnn=null;
        try {
            StrictMode.ThreadPolicy politica= new StrictMode.ThreadPolicy.Builder().permitAll().build();
            cnn = DriverManager.getConnection("jdbc:jtds:sqlserver://;databaseName=09Data;user=consulta;password=zz586;");

        }catch (Exception e){
            Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
        return  cnn;


    public void consulta(){
        try {
            Statement stm = conexionBD().createStatement();
            ResultSet rs = stm.executeQuery("SELECT * FROM ItemSellingPrices WHERE PriceLineID =1 AND ItemID ='" + prod.getText().toString() + "'");



        }catch(Exception e){





android Problem with validating email format in an edittext

I am quite a novice in java and android and I am trying that in an editext that they have to enter an email, when executing an onClick on a button it verifies that the email format is correct, I have already done an if to check that the different fields are not empty but with the email I can't hit the key.
I attach the code to see what you can tell me.

thanks in advance.

It is my first question and I do not know if it is well formulated, you will tell me.

introducir el código aquí

public void onClick (View v) {

            if (validarVacios()) {

                if (esEmailValido(compruebaemail)) {

                    // Gets the data repository in write mode
                    SQLiteDatabase db = Helper.getWritableDatabase();

                    // Create a new map of values, where column names are the keys
                    ContentValues values = new ContentValues();
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA1, txFecVisita.getText().toString());
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA2, txTipoCliente.getText().toString());
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA3, txNombre.getText().toString());
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA4, txApellidos.getText().toString());
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA5, txEmail.getText().toString());
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA6, txTelefono.getText().toString());
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA7, txFecNac.getText().toString());
                    values.put(Estructura_BBDD.NOMBRE_COLUMNA8, txCentroTrabajo.getText().toString());

                    // Insert the new row, returning the primary key value of the new row
                    long newRowId = db.insert(Estructura_BBDD.TABLE_NAME, null, values);

                    Toast.makeText(getApplicationContext(), "!!! Gracias " + txNombre.getText().toString() +
                            " por tu visita a Bosque Suspendido !!!", Toast.LENGTH_LONG).show();

                    // DEJAR LIMPIOS LOS CAMPOS.


            }//fin If


// Validation that there are no empty fields and email format

private boolean validarVacios(){
    boolean vacios = true;
            String c1 = txFecVisita.getText().toString();
            String c2 = txNombre.getText().toString();
            String c3 = txApellidos.getText().toString();
            String c4 = txEmail.getText().toString();
            String c5 = txTelefono.getText().toString();
            String c6 = txFecNac.getText().toString();

            if (c1.isEmpty()){
                txFecVisita.setError("Este campo no puede quedar vacío");
            if (c2.isEmpty()){
                txNombre.setError("Este campo no puede quedar vacío");
            if (c3.isEmpty()){
                txApellidos.setError("Este campo no puede quedar vacío");

            if (c4.isEmpty()){
                txEmail.setError("Este campo no puede quedar vacío");

            if (c5.isEmpty()){
                txTelefono.setError("Este campo no puede quedar vacío");

            if (c6.isEmpty()){
                txFecNac.setError("Este campo no puede quedar vacío");


    return vacios;


private boolean esEmailValido(String email) {
    boolean isValid ;//= true;

    String expression = "^(\w\.-)+@((\w\-)+\.)+(A-Z){2,4}$";
    CharSequence inputStr = email;

    Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(inputStr);
    if (matcher.matches()) {
        isValid = true;

        txEmail.setError("Este campo no ES UN PUTO MAIL");
        isValid = false;

    return isValid;


android – Convert Lettered EditText to double

I have an EditText that has numbers and letters (currency – € 12.00) and I want to change it to double (12.00) to be able to work with it as a number. How can it be done? I've tried it like this but it doesn't work for me:

  double modcuota =  Double.parseDouble(cuota.getText().toString().trim());

java – How to replace EditText of Material Dialog with an AutoCompleteText?

I need to create a dialog that has an AutoCompleteTextView, instead of the EditText that comes as standard. Is there a way to convert this EditText to AutoComplete?

I have a problem with the Bottom Navigation Android Studio when I click on an EditText

It turns out that in a fragment I have an EditText that when I click. the keyboard jumps and the BottomNavigation stays on top of the keyboard.



Join two libraries for edittext in android studio

I have a question that I have not been able to find anywhere and that is why I write it to see who can help me.

I have two libraries,

implementation 'com.hendraanggrian.appcompat: socialview-commons: 0.2'

implementation ''

implementation ''

Both are used to use edittext and textview with a special format,
but what happens is that I need to use both at the same time

This is one of the ways I tried but it doesn't work for me


How to make a dynamic list view? Allow the user to choose how many fields. Android EditText

Hi, I have a form and I need the user to create as many fields as he wants to fill out, for example:
Field Name: John presses +
New_Fields: Fill in, if you want more, press the + button.

Android Studio [EditText] / How can the size of the underline text be enlarged?

As you know, the default Edit Text has a line below that may be 1dp tall. I would like you to measure a little more, like about 3 dp for example. I tried using this xml code as a property of the edit text but it didn't work:


android studio – How to change the Hint of an EditText from the .java file? TextInputLayout

What I am looking for is that through a RadioButton (when selected) change the hint of an EditText, so that it can be displayed at the top of the EditText (as does the voltage).
The hint shown is the one that I place as initial in my xml code, but I don't place any hint in my xml code it doesn't show any hint at the top, and if I put the default power hint in my EditText then when I switch to current the above

Application View

The EditText code is this




And my code that changes the hint is the following

RG_SeleccionC1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId){



                    if (!et_voltajeC1.getText().toString().isEmpty() && !et_SegundoValorC1.getText().toString().isEmpty()){
                        tv_ResultadoC1.setText(CalcularResistencia(VoltajeC1, SegundoValorC1));




                    if (!et_voltajeC1.getText().toString().isEmpty() && !et_SegundoValorC1.getText().toString().isEmpty()){
                        tv_ResultadoC1.setText(CalcularResistencia(VoltajeC1, SegundoValorC1));



How can I do to change the hint and display at the top as the voltage does?