Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.03 KB | None | 0 0
  1. package com.test1.testone;
  2.  
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.support.v7.app.ActionBar;
  5. import android.support.v4.app.Fragment;
  6. import android.app.AlertDialog;
  7. import android.content.DialogInterface;
  8. import android.os.Bundle;
  9. import android.view.LayoutInflater;
  10. import android.view.Menu;
  11. import android.view.MenuItem;
  12. import android.view.View;
  13. import android.view.View.OnClickListener;
  14. import android.view.ViewGroup;
  15. import android.widget.Button;
  16. import android.widget.EditText;
  17. import android.os.Build;
  18.  
  19. public class MainActivity extends ActionBarActivity {
  20.  
  21.     @Override
  22.     protected void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.         setContentView(R.layout.activity_main);
  25.  
  26.         if (savedInstanceState == null) {
  27.             getSupportFragmentManager().beginTransaction()
  28.                     .add(R.id.container, new PlaceholderFragment())
  29.                     .commit();
  30.         }
  31.        
  32.         Button logBtn = (Button) findViewById(R.id.btnLogin);
  33.         logBtn.setOnClickListener(new OnClickListener() {
  34.  
  35.             @Override
  36.             public void onClick(View v) {
  37.                 // Do what you want with the click here
  38.                 AlertDiag();
  39.                
  40.             }
  41.         });
  42.        
  43.     }
  44.  
  45.     @SuppressWarnings("deprecation")
  46.     public void AlertDiag() {
  47.  
  48.         //EditText email = ((EditText) findViewById(R.id.emailInput));
  49.         //EditText pass = ((EditText) findViewById(R.id.passwordInput));
  50.  
  51.     //  String enteredEmail = email.toString();
  52.         //String enteredPass = pass.toString();
  53.  
  54.         AlertDialog alertDialog = new AlertDialog.Builder(this).create();
  55.         alertDialog.setTitle("Button Click..");
  56.         alertDialog.setMessage("test");
  57.         alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
  58.             public void onClick(DialogInterface dialog, int which) {
  59.                 // here you can add functions
  60.             }
  61.         });
  62.         alertDialog.show();
  63.     }
  64.  
  65.  
  66.     @Override
  67.     public boolean onCreateOptionsMenu(Menu menu) {
  68.        
  69.         // Inflate the menu; this adds items to the action bar if it is present.
  70.         getMenuInflater().inflate(R.menu.main, menu);
  71.         return true;
  72.     }
  73.  
  74.     @Override
  75.     public boolean onOptionsItemSelected(MenuItem item) {
  76.         // Handle action bar item clicks here. The action bar will
  77.         // automatically handle clicks on the Home/Up button, so long
  78.         // as you specify a parent activity in AndroidManifest.xml.
  79.         int id = item.getItemId();
  80.         if (id == R.id.action_settings) {
  81.             return true;
  82.         }
  83.         return super.onOptionsItemSelected(item);
  84.     }
  85.  
  86.     /**
  87.      * A placeholder fragment containing a simple view.
  88.      */
  89.     public static class PlaceholderFragment extends Fragment {
  90.  
  91.         public PlaceholderFragment() {
  92.         }
  93.  
  94.         @Override
  95.         public View onCreateView(LayoutInflater inflater, ViewGroup container,
  96.                 Bundle savedInstanceState) {
  97.             View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  98.             return rootView;
  99.         }
  100.     }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement