Soru & Cevap

getText if kullanımı ...

31.01.2016 - 12:06
TextView text = (TextView)findViewById(R.id.yazi);
        String x = text.getText().toString();
        if (x=="hata") {
            Toast.makeText(getApplicationContext(), "hata", Toast.LENGTH_LONG).show();
        }
TextView text = (TextView)findViewById(R.id.postOutput);
        String x = text.getText().toString();
        if ("hata".equals(x)){
            Toast.makeText(getApplicationContext(), "hata", Toast.LENGTH_LONG).show();
        }

İki şekildede olmuyor Textviev de hata yazıyorsa toast çalışmasını istiyorum ama if yapısını yanlış yazıyorum hata veriyor.

 

326 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user mustafaakilli456
mustafaakilli456
31.01.2016 - 02:42
TextView text = (TextView)findViewById(R.id.yazi);

if (text.getText().toString().equals("hata")) {
    Toast.makeText(getApplicationContext(), "hata", Toast.LENGTH_LONG).show();
}