1
這裏是我的代碼,我不知道我在做什麼錯。但它不工作!理想的情況是我想要的是,如果所有的textviews是空的,應該舉杯「請填寫詳細信息」,否則「保存」,但有些怎麼老是乾杯「拯救」我想密碼鎖定我的應用程序,但它不工作
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
EditText et1;
EditText et2;
EditText et3;
EditText et4;
EditText et5;
Button b;
FileOutputStream fos1;
FileOutputStream fos2;
FileOutputStream fos3;
FileOutputStream fos4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=(EditText) findViewById(R.id.editText1);
et2=(EditText) findViewById(R.id.editText2);
et3=(EditText) findViewById(R.id.editText3);
et4=(EditText) findViewById(R.id.editText4);
et5=(EditText) findViewById(R.id.editText5);
b=(Button) findViewById(R.id.button1);
b.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String password=et1.getText().toString();
String confirmPassword=et2.getText().toString();
String secQues=et3.getText().toString();
String secAns=et4.getText().toString();
String hint=et5.getText().toString();
if(password!=null && confirmPassword!=null && secQues!=null && secAns!=null && hint!=null)
{
Toast.makeText(MainActivity.this, "saved", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(MainActivity.this, "Please fill all the details.", Toast.LENGTH_SHORT).show();
}
}
}