Advertisement
Guest User

Untitled

a guest
Jan 18th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. package com.example.secapp;
  2.  
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.support.v7.app.ActionBarActivity;
  7. import android.os.Bundle;
  8. import android.view.Menu;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.widget.Button;
  12. import android.widget.EditText;
  13. import android.widget.Toast;
  14.  
  15.  
  16.  
  17.  
  18. public class MainActivity extends Activity {
  19.  
  20.  
  21.     Context context;
  22.  
  23.  
  24.     EditText login;
  25.     EditText pass;
  26.     Button przycisk;
  27.  
  28.  
  29.     @Override
  30.     protected void onCreate(Bundle savedInstanceState) {
  31.         super.onCreate(savedInstanceState);
  32.         setContentView(R.layout.activity_main);
  33.         context = getApplicationContext();
  34.  
  35.         login = (EditText) findViewById(R.id.editText);
  36.         pass = (EditText) findViewById(R.id.editText2);
  37.  
  38.         przycisk = (Button) findViewById(R.id.button);
  39.         przycisk.setOnClickListener(new View.OnClickListener() {
  40.  
  41.             public void onClick(View v) {
  42.                 Intent intent = new Intent(context, dwa.class);
  43.                 //startActivity(intent);
  44.                 String loginString = login.getText().toString();
  45.                 String passString = pass.getText().toString();
  46.  
  47.                 intent.putExtra("login", loginString);
  48.                 intent.putExtra("pass", passString);
  49.  
  50.                 startActivity(intent);
  51.             }
  52.         });
  53.     }
  54.  
  55.  
  56.     @Override
  57.     public boolean onCreateOptionsMenu(Menu menu) {
  58.         // Inflate the menu; this adds items to the action bar if it is present.
  59.         getMenuInflater().inflate(R.menu.menu_main, menu);
  60.         return true;
  61.     }
  62.  
  63.     @Override
  64.     public boolean onOptionsItemSelected(MenuItem item) {
  65.         // Handle action bar item clicks here. The action bar will
  66.         // automatically handle clicks on the Home/Up button, so long
  67.         // as you specify a parent activity in AndroidManifest.xml.
  68.         int id = item.getItemId();
  69.  
  70.         //noinspection SimplifiableIfStatement
  71.         if (id == R.id.action_settings) {
  72.             return true;
  73.         }
  74.  
  75.         return super.onOptionsItemSelected(item);
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement