Skip to main content
se añadieron 159 caracteres en el cuerpo
Origen Enlace
aldakur
  • 751
  • 1
  • 8
  • 19
public class MainActivity extends AppCompatActivity {

        private TextView result;
        private EditText myName;

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

            result = (TextView) findViewById(R.id.showResult);
            myName= (EditText)findViewById(R.id.NameInput);
            Button getInfo = (Button) findViewById(R.id.getInfoButton);
            getInfo.setOnClickListener(new View.OnClickListener() {



                @Override
                public void onClick(View v) {
                    String inputText = myName.getText().toString();
                    String cadena= inputText.substring(0,1);

                    for(boolean vocal = false;
                    int i=0;ii <inputText= 0;
                    while(i < inputText.length();i++ & !vocal){
                        if((inputText.charAt(i) == 'a') ||
                                (inputText.charAt(i) == 'e')  ||
                                (inputText.charAt(i) == 'i') ||
                                (inputText.charAt(i) == 'o') ||
                                (inputText.charAt(i) == 'u')) {

                            cadena = cadena+inputText.charAt(i);
                            vocal = true;

                        }
                      i++;
                    }
                    result.setText(cadena);
                }
            });

        }
    }
public class MainActivity extends AppCompatActivity {

        private TextView result;
        private EditText myName;

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

            result = (TextView) findViewById(R.id.showResult);
            myName= (EditText)findViewById(R.id.NameInput);
            Button getInfo = (Button) findViewById(R.id.getInfoButton);
            getInfo.setOnClickListener(new View.OnClickListener() {



                @Override
                public void onClick(View v) {
                    String inputText = myName.getText().toString();
                    String cadena= inputText.substring(0,1);

                    for(int i=0;i <inputText.length();i++){
                        if((inputText.charAt(i) == 'a') ||
                                (inputText.charAt(i) == 'e')  ||
                                (inputText.charAt(i) == 'i') ||
                                (inputText.charAt(i) == 'o') ||
                                (inputText.charAt(i) == 'u')) {

                            cadena = cadena+inputText.charAt(i);

                        }
                    }
                    result.setText(cadena);
                }
            });

        }
    }
public class MainActivity extends AppCompatActivity {

        private TextView result;
        private EditText myName;

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

            result = (TextView) findViewById(R.id.showResult);
            myName= (EditText)findViewById(R.id.NameInput);
            Button getInfo = (Button) findViewById(R.id.getInfoButton);
            getInfo.setOnClickListener(new View.OnClickListener() {



                @Override
                public void onClick(View v) {
                    String inputText = myName.getText().toString();
                    String cadena= inputText.substring(0,1);

                    boolean vocal = false;
                    int i = 0;
                    while(i < inputText.length() & !vocal){
                        if((inputText.charAt(i) == 'a') ||
                                (inputText.charAt(i) == 'e')  ||
                                (inputText.charAt(i) == 'i') ||
                                (inputText.charAt(i) == 'o') ||
                                (inputText.charAt(i) == 'u')) {

                            cadena = cadena+inputText.charAt(i);
                            vocal = true;

                        }
                      i++;
                    }
                    result.setText(cadena);
                }
            });

        }
    }
Origen Enlace
aldakur
  • 751
  • 1
  • 8
  • 19

Prueba esto. A mi me funciona.

public class MainActivity extends AppCompatActivity {

        private TextView result;
        private EditText myName;

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

            result = (TextView) findViewById(R.id.showResult);
            myName= (EditText)findViewById(R.id.NameInput);
            Button getInfo = (Button) findViewById(R.id.getInfoButton);
            getInfo.setOnClickListener(new View.OnClickListener() {



                @Override
                public void onClick(View v) {
                    String inputText = myName.getText().toString();
                    String cadena= inputText.substring(0,1);

                    for(int i=0;i <inputText.length();i++){
                        if((inputText.charAt(i) == 'a') ||
                                (inputText.charAt(i) == 'e')  ||
                                (inputText.charAt(i) == 'i') ||
                                (inputText.charAt(i) == 'o') ||
                                (inputText.charAt(i) == 'u')) {

                            cadena = cadena+inputText.charAt(i);

                        }
                    }
                    result.setText(cadena);
                }
            });

        }
    }