Advertisement
kernel_memory_dump

Untitled

Apr 11th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1. package com.example.guip;
  2.  
  3. import android.app.Activity;
  4. import android.app.ActionBar;
  5. import android.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.widget.Button;
  12. import android.widget.RatingBar;
  13. import android.widget.Toast;
  14. import android.os.Build;
  15.  
  16. public class MainActivity extends Activity {
  17.  
  18.     @Override
  19.     protected void onCreate(Bundle savedInstanceState) {
  20.         super.onCreate(savedInstanceState);
  21.         setContentView(R.layout.activity_main);
  22.        
  23.      
  24.     }
  25.  
  26.     // SVAKO  (KLASU) DETE MOZEMO DA GLEDAMO KAO  (KLASU)
  27.     // RODITELJA
  28.     //  View RODITELJ SVIH GUI ELEMENATA
  29.    
  30.     public void metoda1 (View element) {
  31.         // CTRL + SHIFT + O
  32.         // da li je kliknuto na button?
  33.         // BUTTON JE DETE OD VIEW !!!!
  34.         // ako jeste instanceof ce vratiti true
  35.         // tada znamo da imamo button!
  36.        
  37.         if (element instanceof Button){
  38.             Button elementKaoButton = (Button) element;
  39.             Toast.makeText(getApplicationContext(),elementKaoButton.getText(), Toast.LENGTH_LONG).show();
  40.         }
  41.     }
  42.    
  43.     public void opisOcene (View element) {
  44.         if (element instanceof RatingBar){
  45.             RatingBar rb = (RatingBar) element;
  46.             String opis;
  47.             int brZvezda;
  48.            
  49.             brZvezda = rb.getNumStars();
  50.             if (brZvezda == 5){
  51.                 opis = "Odlican!";
  52.             } else if(brZvezda == 4){
  53.                 opis = "Vrlo dobar!";
  54.             } else if (brZvezda == 3){
  55.                 opis = "Dobar!";
  56.             } else if (brZvezda == 2){
  57.                
  58.             }
  59.            
  60.             Toast.makeText(getApplicationContext(), opis, Toast.LENGTH_LONG).show();
  61.         }
  62.        
  63.     }
  64.    
  65.  
  66.     @Override
  67.     public boolean onCreateOptionsMenu(Menu menu) {
  68.        
  69.         // Inflate the menu; this adds items to the action bar if it is present.
  70.         getMenuInflater().inflate(R.menu.main, menu);
  71.         return true;
  72.     }
  73.  
  74.     @Override
  75.     public boolean onOptionsItemSelected(MenuItem item) {
  76.         // Handle action bar item clicks here. The action bar will
  77.         // automatically handle clicks on the Home/Up button, so long
  78.         // as you specify a parent activity in AndroidManifest.xml.
  79.         int id = item.getItemId();
  80.         if (id == R.id.action_settings) {
  81.             return true;
  82.         }
  83.         return super.onOptionsItemSelected(item);
  84.     }
  85.  
  86.  
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement