Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.rubel.teammate;
- import android.app.AlertDialog;
- import android.content.DialogInterface;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.text.Editable;
- import android.text.InputType;
- import android.util.Log;
- import android.widget.EditText;
- public class MainActivity extends AppCompatActivity {
- private String m_Text = "";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- // AlertDialog.Builder alert = new AlertDialog.Builder(this);
- //
- // alert.setTitle("Registration");
- // alert.setMessage("Server Name:");
- // // Set an EditText view to get user input
- // final EditText servername = new EditText(this);
- // alert.setView(servername);
- //
- // alert.setMessage("User Name:");
- // // Set an EditText view to get user input
- // final EditText username = new EditText(this);
- // alert.setView(username);
- //
- // alert.setMessage("Password:");
- // // Set an EditText view to get user input
- // final EditText password = new EditText(this);
- // //alert.setView(password);
- //
- // alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
- // public void onClick(DialogInterface dialog, int whichButton) {
- // String value1 = servername.getText().toString();
- // String value2 = username.getText().toString();
- // String value3 = password.getText().toString();
- // // Do something with value!
- // }
- // });
- //
- alertOneButton();
- String name = utils.getPreference(getApplicationContext(),"username");
- Log.d("name",name);
- }
- public void alertOneButton() {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Title");
- // Set up the input
- final EditText input = new EditText(this);
- // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
- //input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
- input.setInputType(InputType.TYPE_CLASS_TEXT);
- builder.setView(input);
- // Set up the buttons
- builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- m_Text = input.getText().toString();
- //Log.d("Name", m_Text);
- utils.savePreference(getApplicationContext(),"username",m_Text);
- }
- });
- builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
- builder.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement