2012-02-05 4 views
0
public void createpass() { 
//set up dialog 
final Dialog dialog = new Dialog(App.this); 
dialog.setContentView(R.layout.createpass); 
dialog.setTitle("Set Password"); 
dialog.setCancelable(false); 
//there are a lot of settings, for dialog, check them all out! 

//set up text 
final EditText text = (EditText) dialog.findViewById(R.id.editText1); 
text.setText(""); 
//set up text 
final EditText text2 = (EditText) dialog.findViewById(R.id.editText2); 
text2.setText(""); 



//set up button 
Button button = (Button) dialog.findViewById(R.id.Button01); 
button.setOnClickListener(new OnClickListener() { 
@Override 
    public void onClick(View v) { 

    String createpass_password = text.getText().toString().trim(); 
    String createpass_password2 = text2.getText().toString().trim(); 


    try 
    { 
     if(createpass_password == createpass_password2) 
     { 
      FileWriter fstream = new FileWriter("/data/data/folder.hide.alexander.fuchs/password.db"); 
      BufferedWriter out = new BufferedWriter(fstream); 
      out.write(createpass_password); 
      //Close the output stream 
      out.close();  
     dialog.dismiss(); 
     } 
     else 
     { 
      toaster("Passwords are not matching !"); 
      text.setText(""); 
      text2.setText(""); 
     } 
    } 
    catch(Exception x) 
    {  
     String ErrorMessage = x.getMessage(); 
     toaster("Error"); 
     finish(); 
    } 

} 
}); 
//now that the dialog is set up, it's time to show it 

    dialog.show(); 

} 

나는 그들이 동일한 해야 글고, 의 값에 액세스하려고하지만 그들은 내가 암호 대화 를 만들려고안드로이드 사용자 정의 대화 글고

하지 않으며 암호가있는 경우 "를 통해 확인 확인 또 "

는 대화 상자가 제대로 나타납니다하지만 난 는 구조가 같지 않은 그들을보고하는 경우 같은 값을 입력 할 때

답변

3

당신은을 사용해야합니다String 콘텐츠를 테스트하십시오.

== 개체 참조가 동일한 지 여부를 테스트합니다.

그래서 코드에서 당신은 할 필요가 :

if (createpass_password.equals(createpass_password2)) { 
관련 문제