gagan93

Java code for MainActivity, Second Android App

Feb 14th, 2014
129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //package com.example.userid; you may choose to write your own package name
  2.  
  3.  
  4. import android.app.Activity;
  5. import android.os.Bundle;
  6. import android.view.Menu;
  7. import android.view.View;
  8.  
  9. public class MainActivity extends Activity {
  10.  
  11.     Button submit;
  12.     EditText userId,password;  
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.activity_main);
  17.        
  18.         submit   = (Button)findViewById(R.id.button1);
  19.         userId   = (EditText)findViewById(R.id.editText1);
  20.         password = (EditText)findViewById(R.id.editText2);
  21.        
  22.         submit.setOnClickListener(new OnClickListener() {
  23.            
  24.             @Override
  25.             public void onClick(View arg0) {
  26.                 // TODO Auto-generated method stub
  27.                 Toast.makeText(getBaseContext(), "User id is "+userId.getText().toString()+
  28.                     "\nPassword is "+password.getText().toString(), Toast.LENGTH_LONG).show();
  29.             }
  30.         });
  31.     }
  32.  
  33. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×