document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*Java Class*/
  2. package com.antonioblescia.oreproduzione;
  3.  
  4. import android.os.Bundle;
  5. import android.app.Activity;
  6. import android.view.Menu;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.Toast;
  11.  
  12. public class Home extends Activity implements View.OnClickListener {
  13.  
  14.     EditText txtPezziDaProdurre,txtGiaProdotti,txtNumeroImpronte,txtCicloProduzione;
  15.     Button btnCalcola;
  16.     @Override
  17.     protected void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.activity_home);
  20.  
  21.         /*Binding*/
  22.         txtPezziDaProdurre = (EditText)findViewById(R.id.txtPezziDaProdurre);
  23.         txtGiaProdotti = (EditText)findViewById(R.id.txtGiaProdotti);
  24.         txtNumeroImpronte = (EditText)findViewById(R.id.txtNumeroImpronte);
  25.         txtCicloProduzione = (EditText)findViewById(R.id.txtCicloProduzione);
  26.  
  27.         btnCalcola = (Button) findViewById(R.id.btnCalcola);
  28.         btnCalcola.setOnClickListener(this);
  29.     }
  30.  
  31.  
  32.     @Override
  33.     public boolean onCreateOptionsMenu(Menu menu) {
  34.         // Inflate the menu; this adds items to the action bar if it is present.
  35.         getMenuInflater().inflate(R.menu.home, menu);
  36.         return true;
  37.     }
  38.  
  39.     @Override
  40.     public void onClick(View view) {
  41.         switch (view.getId()){
  42.             case R.id.btnCalcola:
  43.                 calcola();
  44.                 break;
  45.  
  46.         }
  47.     }
  48.  
  49.     private void calcola(){
  50.         int pezziDaProdurre = Integer.parseInt(txtPezziDaProdurre.getText().toString());
  51.         int giaProdotti = Integer.parseInt(txtGiaProdotti.getText().toString());
  52.         int numeroImpronte = Integer.parseInt(txtNumeroImpronte.getText().toString());
  53.         int cicloProduzione = Integer.parseInt(txtCicloProduzione.getText().toString());
  54.  
  55.         float J = pezziDaProdurre - giaProdotti;
  56.         float W = (60/cicloProduzione)*numeroImpronte*60;
  57.  
  58.         float oreProduzione = J/W;
  59.         Toast.makeText(getApplicationContext(),"Ore di Produzione:"+Float.toString(oreProduzione),Toast.LENGTH_LONG).show();
  60.  
  61.     }
  62. }
  63.  
  64. /*XML Layout */
  65. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  66.     xmlns:tools="http://schemas.android.com/tools"
  67.     android:layout_width="match_parent"
  68.     android:layout_height="match_parent"
  69.     android:paddingLeft="@dimen/activity_horizontal_margin"
  70.     android:paddingRight="@dimen/activity_horizontal_margin"
  71.     android:paddingTop="@dimen/activity_vertical_margin"
  72.     android:paddingBottom="@dimen/activity_vertical_margin"
  73.     tools:context=".Home"
  74.     android:orientation="vertical">
  75.  
  76.     <TableLayout
  77.             android:layout_width="fill_parent"
  78.             android:layout_height="wrap_content"
  79.             android:layout_gravity="center_horizontal|top">
  80.  
  81.         <TableRow
  82.                 android:layout_width="fill_parent"
  83.                 android:layout_height="fill_parent">
  84.  
  85.             <TextView
  86.                     android:layout_width="wrap_content"
  87.                     android:layout_height="wrap_content"
  88.                     android:textAppearance="?android:attr/textAppearanceMedium"
  89.                     android:text="Pezzi da produrre:"
  90.                     android:id="@+id/textView"/>
  91.  
  92.             <EditText
  93.                     android:layout_width="wrap_content"
  94.                     android:layout_height="wrap_content"
  95.                     android:inputType="number"
  96.                     android:ems="10"
  97.                     android:id="@+id/txtPezziDaProdurre"/>
  98.         </TableRow>
  99.  
  100.         <TableRow
  101.             android:layout_width="fill_parent"
  102.             android:layout_height="fill_parent">
  103.  
  104.         <TextView
  105.                 android:layout_width="wrap_content"
  106.                 android:layout_height="wrap_content"
  107.                 android:textAppearance="?android:attr/textAppearanceMedium"
  108.                 android:text="GiĆ  prodotti:"
  109.                 android:id="@+id/textView2"/>
  110.  
  111.         <EditText
  112.                 android:layout_width="wrap_content"
  113.                 android:layout_height="wrap_content"
  114.                 android:inputType="number"
  115.                 android:ems="10"
  116.                 android:id="@+id/txtGiaProdotti"/>
  117.     </TableRow>
  118.  
  119.         <TableRow
  120.                 android:layout_width="fill_parent"
  121.                 android:layout_height="fill_parent">
  122.  
  123.             <TextView
  124.                     android:layout_width="wrap_content"
  125.                     android:layout_height="wrap_content"
  126.                     android:textAppearance="?android:attr/textAppearanceMedium"
  127.                     android:text="Numero impronte"
  128.                     android:id="@+id/textView3"/>
  129.  
  130.             <EditText
  131.                     android:layout_width="wrap_content"
  132.                     android:layout_height="wrap_content"
  133.                     android:inputType="number"
  134.                     android:ems="10"
  135.                     android:id="@+id/txtNumeroImpronte"/>
  136.         </TableRow>
  137.         <TableRow
  138.                 android:layout_width="fill_parent"
  139.                 android:layout_height="fill_parent">
  140.  
  141.             <TextView
  142.                     android:layout_width="wrap_content"
  143.                     android:layout_height="wrap_content"
  144.                     android:textAppearance="?android:attr/textAppearanceMedium"
  145.                     android:text="Ciclo Produzione"
  146.                     android:id="@+id/textView4"/>
  147.  
  148.             <EditText
  149.                     android:layout_width="wrap_content"
  150.                     android:layout_height="wrap_content"
  151.                     android:inputType="number"
  152.                     android:ems="10"
  153.                     android:id="@+id/txtCicloProduzione"/>
  154.         </TableRow>
  155.  
  156.     </TableLayout>
  157.  
  158.     <LinearLayout
  159.             android:orientation="vertical"
  160.             android:layout_width="fill_parent"
  161.             android:layout_height="wrap_content"
  162.             android:gravity="center_horizontal">
  163.  
  164.         <Button
  165.                 android:layout_width="wrap_content"
  166.                 android:layout_height="wrap_content"
  167.                 android:text="Calcola"
  168.                 android:id="@+id/btnCalcola"/>
  169.     </LinearLayout>
  170. </LinearLayout>
');