1

次の条件を指定して、「boton_continuar」ボタンをクリックするとトーストを表示しようとしています:EditExtvacuum(numero_celular)およびckeckbox(check)チェックなし。これは私のコードです

boton_continuar.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View arg0) {
        //Verificamos que se halla clikeado y se halla ingresado
        if(check.isChecked() && numero_celular.getText().length() != 0){

            Intent intent = new Intent(RegisterActivity.this, PrincipalActivity.class);
            startActivity(intent);
        }else{
            Context contexto = getApplicationContext();
            if(!check.isChecked()){                 
                Toast.makeText(contexto, "Debe aceptar los términos", 2000);
            }
            if(numero_celular.getText().length() == 0){
                Toast.makeText(contexto, "Debe ingresar su número", 2000);
            }
    }
}});
4

5 に答える 5

9

.show()乾杯後は必ずお電話ください。

boton_continuar.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View arg0) {
        //Verificamos que se halla clikeado y se halla ingresado
        if(check.isChecked() && numero_celular.getText().length() != 0){
            Intent intent = new Intent(RegisterActivity.this, PrincipalActivity.class);
            startActivity(intent);
        } else {
            Context contexto = getApplicationContext();
            if(!check.isChecked()){                 
                Toast.makeText(contexto, "Debe aceptar los términos", 2000).show();
            }
            if(numero_celular.getText().length() == 0){
                Toast.makeText(contexto, "Debe ingresar su número", 2000).show();
            }
        }
    }});
于 2014-01-06T22:07:57.150 に答える
3

2つのこと:

  1. .show()作成したトーストを呼び出します。
  2. 2000Toast の有効なパラメーターではありません。それは2000ミリ秒表示されません。Toast が受け入れる唯一のパラメーターは、Toast.LENGTH_SHORTまたはToast.LENGTH_LONG

そう:

次の行を変更します。

Toast.makeText(contexto, "Debe aceptar los términos", 2000);
Toast.makeText(contexto, "Debe ingresar su número", 2000);

これらの行に:

Toast.makeText(contexto, "Debe aceptar los términos", Toast.LENGTH_SHORT).show();
Toast.makeText(contexto, "Debe ingresar su número", Toast.LENGTH_SHORT).show();

Toast.LENGTH_SHORTは 2000 ミリ秒 (2 秒)、Toast.LENGTH_LONG3500 ミリ秒 (3.5 秒) です。

  • Toast.LENGTH_SHORT == 0代わりにis を渡すことができます0
  • Toast.LENGTH_LONG == 1代わりに渡すことができます1

詳細については、 Android のドキュメントを参照しToastてください。

于 2014-01-06T22:12:16.477 に答える
1

SHOW 関数を使用する必要があります。

行う:

Toast.makeText(contexto, "Debe ingresar su número", 2000).show();
于 2014-01-06T22:08:35.003 に答える
1

「Toast.makeText()」の後に「.show()」を追加する必要があります。

例えば:

if(!check.isChecked()){                 
            Toast.makeText(contexto, "Debe aceptar los términos", 2000).show();
            }
            if(numero_celular.getText().length() == 0){
                Toast.makeText(contexto, "Debe ingresar su número", 2000).show();
            }
于 2014-01-06T22:11:57.633 に答える
0

次のことを試してください。

 boton_continuar.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View arg0) {
        //Verificamos que se halla clikeado y se halla ingresado
        if(check.isChecked() && numero_celular.getText().length() != 0){


            Intent intent = new Intent(RegisterActivity.this, PrincipalActivity.class);
            startActivity(intent);
        }else{
            Context contexto = getApplicationContext();
            if(!check.isChecked()){                 
                Toast.makeText(contexto, "Debe aceptar los términos", 2000).show();
            }
            if(numero_celular.getText().length() == 0){
                Toast.makeText(contexto, "Debe ingresar su número", 2000).show();
            }


        }

    }});

Toast を表示するには、Toastを呼び出す必要があり.show()ます。

于 2014-01-06T22:08:10.933 に答える