Guest User

MainActivity

a guest
Jun 23rd, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. package com.simonic.testapp;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.view.Menu;
  6. import android.view.MenuItem;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.Toast;
  11.  
  12. public class MainActivity extends Activity {
  13.  
  14. final EditText zahleneingabe = (EditText)findViewById(R.id.txtn);
  15. Button savebutton = (Button)findViewById(R.id.savebutton);
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.activity_main);
  20.  
  21. savebutton.setOnClickListener(new View.OnClickListener() {
  22.  
  23. @Override
  24. public void onClick(View v) {
  25. Toast toast = new Toast(getApplicationContext());
  26. toast.setGravity(100, 100, 100);
  27. Toast.makeText(MainActivity.this, zahleneingabe.getText(), Toast.LENGTH_SHORT).show();
  28.  
  29. }
  30. });
  31.  
  32. }
  33.  
  34. @Override
  35. public boolean onCreateOptionsMenu(Menu menu) {
  36. // Inflate the menu; this adds items to the action bar if it is present.
  37. getMenuInflater().inflate(R.menu.main, menu);
  38. return true;
  39. }
  40.  
  41. @Override
  42. public boolean onOptionsItemSelected(MenuItem item) {
  43. // Handle action bar item clicks here. The action bar will
  44. // automatically handle clicks on the Home/Up button, so long
  45. // as you specify a parent activity in AndroidManifest.xml.
  46. int id = item.getItemId();
  47. if (id == R.id.action_settings) {
  48. return true;
  49. }
  50. return super.onOptionsItemSelected(item);
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment