Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package project.login;
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- public class LoginActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- Button launch = (Button)findViewById(R.id.login_button);
- launch.setOnClickListener( new OnClickListener ()
- {
- public void onClick(View view)
- { EditText usernameEditText = (EditText) findViewById(R.id.username);
- EditText passwordEditText = (EditText) findViewById(R.id.password);
- String sUsername = usernameEditText.getText().toString();
- String sPassword = passwordEditText.getText().toString();
- if(usernameEditText == null || passwordEditText == null) {
- new AlertDialog.Builder(this)
- .setTitle("Error")
- .setMessage("You can't let the fields empty")
- .show();
- }
- }
- }
- );
- }
- }
- new AlertDialog.Builder(LoginActivity.this)
- .setTitle("Error")
- .setMessage("You can't let the fields empty")
- .show();
- Don't forget to import android.app.AlertDialog first.
- AlertDialog alert = new AlertDialog.Builder(this).create();
- alert.setTitle("Error");
- alert.setMessage("Sorry, your device doesn't support flash light!");
- alert.setButton(Dialog.BUTTON_POSITIVE,"OK",new DialogInterface.OnClickListener(){
- @Override
- public void onClick(DialogInterface dialog, int which) {
- finish();
- }
- });
- alert.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement