SHARE
TWEET

Untitled

a guest Mar 18th, 2014 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.geert.moneyconverter;
  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.os.Bundle;
  7. import android.view.LayoutInflater;
  8. import android.view.Menu;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. //import android.os.Build;
  13. import android.widget.Button;
  14. import android.widget.EditText;
  15. import android.widget.Toast;
  16.  
  17. public class MainActivity extends ActionBarActivity {
  18.  
  19.     EditText mEtxtAmount;
  20.     Button mBtnCalculate;
  21.    
  22.     @Override
  23.     protected void onCreate(Bundle savedInstanceState) {
  24.         super.onCreate(savedInstanceState);
  25.         setContentView(R.layout.activity_main);
  26.        
  27.         mEtxtAmount = (EditText) findViewById(R.id.etxtAmount);
  28.         mBtnCalculate = (Button) findViewById(R.id.btnCalculate);
  29.  
  30.         if (savedInstanceState == null) {
  31.             getSupportFragmentManager().beginTransaction()
  32.                     .add(R.id.container, new PlaceholderFragment())
  33.                     .commit();
  34.         }
  35.     }
  36.  
  37. //IK KRIJG HIER STEEDS DE ERROR, MAAR WEL ALS TOAST.
  38. //HIJ PAKT DE IF(VIEW==MBTNCALCULATE) DUS ALS FALSE, EN DAN DE ELSE.
  39.     public void calculateToDollars(View view){
  40.         /* if ( view == mBtnCalculate){
  41.                 float euros = Float.valueOf(mEtxtAmount.getText().toString());
  42.                 float dollars =  (float) 1.36 * euros;
  43.                 Toast.makeText(this, "€ " + euros + " is evenveel waard als $ " + dollars, Toast.LENGTH_LONG).show();
  44.          }
  45.          else{
  46.                  Toast.makeText(this, "Error!", Toast.LENGTH_LONG).show();
  47.          }*/
  48.         Log.d("id controle","view ='"+view.getId()+"'   btnCalculate = '"+btnCalculate.getId()"'");
  49.  
  50.         if(view.getId()== R.id.btnCalculate){
  51.         float euros = Float.valueOf(mEtxtAmount.getText().toString());
  52.                 float dollars =  (float) 1.36 * euros;
  53.                 Toast.makeText(this, "€ " + euros + " is evenveel waard als $ " + dollars, Toast.LENGTH_LONG).show();
  54.         } else{
  55.                  Toast.makeText(this, "Error!", Toast.LENGTH_LONG).show();
  56.          }
  57.    }
  58.  
  59.     @Override
  60.     public boolean onCreateOptionsMenu(Menu menu) {
  61.        
  62.         // Inflate the menu; this adds items to the action bar if it is present.
  63.         getMenuInflater().inflate(R.menu.main, menu);
  64.         return true;
  65.     }
  66.  
  67.     @Override
  68.     public boolean onOptionsItemSelected(MenuItem item) {
  69.         // Handle action bar item clicks here. The action bar will
  70.         // automatically handle clicks on the Home/Up button, so long
  71.         // as you specify a parent activity in AndroidManifest.xml.
  72.         int id = item.getItemId();
  73.         if (id == R.id.action_settings) {
  74.             return true;
  75.         }
  76.         return super.onOptionsItemSelected(item);
  77.     }
  78.  
  79.     /**
  80.      * A placeholder fragment containing a simple view.
  81.      */
  82.     public static class PlaceholderFragment extends Fragment {
  83.  
  84.         public PlaceholderFragment() {
  85.         }
  86.  
  87.         @Override
  88.         public View onCreateView(LayoutInflater inflater, ViewGroup container,
  89.                 Bundle savedInstanceState) {
  90.             View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  91.             return rootView;
  92.         }
  93.     }
  94. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top