Advertisement
kernel_memory_dump

Untitled

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