Advertisement
Guest User

Untitled

a guest
Oct 16th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. public class MainActivity extends AppCompatActivity { public static final String TAG = MainActivity.class.getSimpleName(); private EditText username; private EditText useremail; private EditText userpassword; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); username = (EditText)findViewById(R.id.name); useremail = (EditText)findViewById(R.id.email); userpassword = (EditText)findViewById(R.id.password); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //get user details entered into editText views String name = username.getText().toString(); String email = useremail.getText().toString(); String password = userpassword.getText().toString(); //display user entered details as log messages Log.d(TAG, “user name: ” + name); Log.d(TAG, “user email: ” + email); Log.d(TAG, “user password : ” + password); //display user entered details as Toast message Toast.makeText(getApplicationContext(),name + ” ” +email + ” “+ password, Toast.LENGTH_LONG).show(); //display user entered details in snack bar Snackbar.make(view, name + ” ” +email + ” “+ password, Snackbar.LENGTH_LONG).show(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement