Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class RegisterDialogFragment extends DialogFragment {
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState){
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- LayoutInflater inflater = getActivity().getLayoutInflater();
- View v = inflater.inflate(R.layout.register_layout,null);
- final EditText retUsername = (EditText) v.findViewById(R.id.rusername);
- final EditText retPassword = (EditText)v.findViewById(R.id.rpassword);
- final EditText retCredits = (EditText)v.findViewById(R.id.rcredits);
- builder.setView(v).setPositiveButton(R.string.register,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- String username, password, credits;
- username = retUsername.getText().toString();
- password = retPassword.getText().toString();
- credits = retCredits.getText().toString();
- String msg;
- if((username.equalsIgnoreCase(""))){
- msg = "Username Taken, Please input another one";
- }
- else{
- doAdd();
- msg = "User Created";
- slotmachine();
- }
- Toast.makeText(context,msg,Toast.LENGTH_SHORT).show();
- }
- })
- .setNegativeButton(R.string.exit,new DialogInterface.OnClickListener(){
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- }
- );
- return builder.create();
- }
- }
- public void doAdd(View v){
- DBase db = new DBase(this);
- EditText etrusername = (EditText) findViewById(R.id.rusername);
- EditText etrpassword = (EditText) findViewById(R.id.rpassword);
- EditText etrcredits = (EditText) findViewById(R.id.rcredits);
- db.open();
- db.add(etrusername.toString(),Integer.parseInt(etrpassword.toString()),Integer.parseInt(etrcredits.toString()));
- db.close();
- }
Add Comment
Please, Sign In to add comment