Advertisement
kernel_memory_dump

Untitled

Jan 27th, 2014
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.76 KB | None | 0 0
  1. package rajak.sebastian.digidroid;
  2.  
  3. import android.os.Bundle;
  4. import android.app.Activity;
  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.     private EditText txtRez;
  15.     private int prviOperand;
  16.     private int drugiOperand;
  17.    
  18.     private final int PLUS = 1;
  19.     private final int MINUS = 2;
  20.     private final int PUTA  = 3;
  21.     private final int PODELJENO = 4;
  22.    
  23.    
  24. // A + B = C
  25.    
  26.     private boolean unetPrvi;
  27.     private boolean unetDrugi;
  28.    
  29.    
  30.    
  31.  
  32.     @Override
  33.     protected void onCreate(Bundle savedInstanceState) {
  34.         super.onCreate(savedInstanceState);
  35.         setContentView(R.layout.activity_main);
  36.        
  37.        
  38.     }
  39.    
  40.     public void sabiranje(View btnPlus){
  41.        
  42.        
  43.        
  44.     }
  45.    
  46.     public void upisiVrednost(View btnNekiBroj){
  47.        
  48.         Button dugme = (Button) btnNekiBroj;
  49.         String cifra = (String) dugme.getText();
  50.  
  51.        
  52.    
  53.  
  54.  
  55.        
  56.         // "1"
  57.         // "4"
  58.         // "4" + "1"
  59.         // "41"
  60.        
  61.         if ( !unetPrvi){
  62.            
  63.             String prviOperandKaoString = "" + prviOperand;
  64.             prviOperandKaoString += cifra;
  65.             // 12345
  66.             int vrednost = Integer.parseInt(prviOperandKaoString);
  67.             prviOperand = vrednost;
  68.             Toast.makeText(getApplicationContext(), prviOperandKaoString,
  69.                        Toast.LENGTH_LONG).show();
  70.             txtRez.setText(prviOperandKaoString);
  71.            
  72.        
  73.            
  74.         }
  75.        
  76.         else if(!unetDrugi){
  77.             String drugiOperandKaoString = "" + drugiOperand;
  78.             drugiOperandKaoString += cifra;
  79.             int vrednost = Integer.parseInt(drugiOperandKaoString);
  80.             drugiOperand = vrednost;
  81.             Toast.makeText(getApplicationContext(), drugiOperandKaoString,
  82.                        Toast.LENGTH_LONG).show();
  83.             txtRez.setText(drugiOperandKaoString);
  84.         }
  85.        
  86.  
  87.        
  88.     }
  89.    
  90.  
  91.     public boolean onCreateOptionsMenu (Menu menu){
  92.           super.onCreateOptionsMenu(menu);
  93.            CreateMenu(menu);
  94.            return true;
  95.     }
  96.      
  97.     private void CreateMenu(Menu menu){
  98.         MenuItem opcija1 = menu.add(0,0,0,"Prva opcija");
  99.         {
  100.             opcija1.setIcon(R.drawable.ic_launcher);
  101.             opcija1.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  102.         }
  103.      
  104.         MenuItem opcija2 = menu.add(0,1,1,"Prva opcija");
  105.         {
  106.             opcija2.setIcon(R.drawable.ic_launcher);
  107.             opcija2.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  108.         }
  109.      
  110.     }
  111.      
  112.     public boolean onOptionsItemSelected (MenuItem item){
  113.             return MenuChoice(item);
  114.     }
  115.      
  116.     private boolean MenuChoice (MenuItem item){
  117.        
  118.     switch( item.getItemId()){
  119.        case 0:
  120.            Toast.makeText(this, "Izabrali ste prvu opciju 1", Toast.LENGTH_LONG).show();
  121.           return true;
  122.        case 1:
  123.          Toast.makeText(this, "Izabrali ste drugu opciju 2" , Toast.LENGTH_LONG).show();
  124.      
  125.     }
  126.     return true;
  127.     }
  128.  
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement