Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.simonic.testapp;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- public class MainActivity extends Activity {
- final EditText zahleneingabe = (EditText)findViewById(R.id.txtn);
- Button savebutton = (Button)findViewById(R.id.savebutton);
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- savebutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Toast toast = new Toast(getApplicationContext());
- toast.setGravity(100, 100, 100);
- Toast.makeText(MainActivity.this, zahleneingabe.getText(), Toast.LENGTH_SHORT).show();
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment