SORU
6 AĞUSTOS 2010, Cuma


Nasıl bir uyarı iletişim iki metin alanları düzenlemek için

Bir kullanıcı adı ve android bir parola istemi için bir uyarı iletişim kullanmaya çalışıyorum. Bu kod here: buldum

  if (token.equals("Not Found"))
    {
        LayoutInflater factory = LayoutInflater.from(this);            
        final View textEntryView = factory.inflate(R.layout.userpasslayout, null);

        AlertDialog.Builder alert = new AlertDialog.Builder(this); 

        alert.setTitle("Please Login to Fogbugz"); 
        alert.setMessage("Enter your email and password"); 
        // Set an EditText view to get user input  
        alert.setView(textEntryView); 
        AlertDialog loginPrompt = alert.create();

        final EditText input1 = (EditText) loginPrompt.findViewById(R.id.username);
        final EditText input2 = (EditText) loginPrompt.findViewById(R.id.password);

        alert.setPositiveButton("Login", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 
            input1.getText().toString(); **THIS CRASHES THE APPLICATION**


        } 
        }); 

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, int whichButton) { 
            // Canceled. 
          } 
        }); 

        alert.show(); 

    }

EDİT: uygun bir düzeni kurmak, ama metin alanına erişmeye çalıştığımda bir hata almayı başardı. Buradaki sorun nedir?

CEVAP
26 AĞUSTOS 2010, PERŞEMBE


kontrol uyarı kutusuna bu kodu textview, Tamam ' ı tıklatın ekranda tost kullanarak görüntüler düzenlemek.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final AlertDialog.Builder alert = new AlertDialog.Builder(this);
    final EditText input = new EditText(this);
    alert.setView(input);
    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString().trim();
            Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show();
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });
    alert.show();               
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • bashirsultani

    bashirsultan

    22 Mart 2010
  • glowpinkstah

    glowpinkstah

    16 Mayıs 2006
  • Mark Halberstadt

    Mark Halbers

    19 ŞUBAT 2010