Mgamerz

Untitled

Jul 1st, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.40 KB | None | 0 0
  1. import android.app.Activity;
  2. import android.app.Dialog;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.util.Log;
  6. import android.view.Menu;
  7. import android.view.MenuInflater;
  8. import android.view.MenuItem;
  9. import android.view.View;
  10. import android.widget.Button;
  11. import android.widget.ImageView;
  12. import android.widget.TextView;
  13.  
  14. public class Landing extends Activity {
  15.     private String tag = "XXX";
  16.     /** Called when the activity is first created. */
  17.     @Override
  18.     public void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.landing);
  21.        
  22.     }
  23.     private void showEula() {
  24.         Dialog dialog = new Dialog(this);
  25.         dialog.setContentView(R.layout.eula);
  26.         dialog.setTitle("This is my custom dialog box");
  27.         dialog.setCancelable(true);
  28.         //there are a lot of settings, for dialog, check them all out!
  29.         //set uptext
  30.         TextView text = (TextView) dialog.findViewById(R.id.TextView01);
  31.         text.setText("HELLO");
  32.         //set up image view
  33.         ImageView img = (ImageView) dialog.findViewById(R.id.ImageView01);
  34.         img.setImageResource(R.drawable.icon);
  35.  
  36.         //set up button
  37.         Button button = (Button) dialog.findViewById(R.id.Button01);
  38.         button.setOnClickListener(new View.OnClickListener() {
  39.         @Override
  40.             public void onClick(View v) {
  41.                 finish();
  42.             }
  43.         });
  44.         //now that the dialog is set up, it's time to show it    
  45.         dialog.show();
  46.     }
  47.  
  48.     // Called first time user clicks on the menu button
  49.     @Override
  50.     public boolean onCreateOptionsMenu(Menu menu) {
  51.         MenuInflater inflater = getMenuInflater(); //
  52.         inflater.inflate(R.menu.menu, menu); //
  53.         return true; //
  54.     }
  55.  
  56.     // Called when an options item is clicked
  57.     @Override
  58.     public boolean onOptionsItemSelected(MenuItem item) {
  59.         Log.i(tag,item.toString()+" "+item.getItemId());
  60.         Log.i(tag,"PrefsID: "+R.id.itemPrefs);
  61.         switch (item.getItemId()) {
  62.         case R.id.itemPrefs:           
  63.             startActivity(new Intent(this, PrefsActivity.class));
  64.             Log.i("Mgamerz Productions Cryptographer", "User chose Preferences");
  65.             break;
  66.        
  67.         case R.id.itemSensors:
  68.             startActivity(new Intent(this, SensorsActivity.class));
  69.             break;
  70.        
  71.         case R.id.itemDecrypt:
  72.             showEula();
  73.             break;
  74.            
  75.         default:
  76.             Log.e(tag,"User didn't choose anything?");
  77.         }
  78.         return true; //
  79.     }
Advertisement
Add Comment
Please, Sign In to add comment