- Anasayfa
- Android
- Android RatingBar Kullanımı ve Örneği
Android RatingBar Kullanımı ve Örneği
Android RatingBar derecelendirmesini kullanıcıdan almak için kullanılabilir. Derecelendirme, kayan nokta sayıları döndürür. 2.0, 3.5, 4.0 vb. Olabilir.
Android RatingBar derecelendirmesini yıldızlarla görüntüler. Android RatingBar, AbsSeekBar sınıfının alt sınıfıdır.
Android RatingBar sınıfının getRating () yöntemi, puanlama numarasını döndürür.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <RatingBar android:id="@+id/ratingBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="18dp" /> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="121dp" android:textSize="25dp" android:text="Webinyo.COM" android:layout_below="@+id/ratingBar" android:layout_centerHorizontal="true" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/ratingBar" android:layout_centerHorizontal="true" android:layout_marginTop="41dp" android:text="GÖNDER" /> </RelativeLayout>
MainActivity.java
import android.os.Bundle; import android.app.Activity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.RatingBar; import android.widget.Toast; public class MainActivity extends Activity { RatingBar ratingbar1; Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); addListenerOnButtonClick(); } public void addListenerOnButtonClick(){ ratingbar1=(RatingBar)findViewById(R.id.ratingBar); button=(Button)findViewById(R.id.button2); //Performing action on Button Click button.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { //Getting the rating and displaying it on the toast String rating=String.valueOf(ratingbar1.getRating()); Toast.makeText(getApplicationContext(), rating, Toast.LENGTH_LONG).show(); } }); } }
Etiketler
Activity and Intent alarm manager android android dersler android kodlar android ratingbar android ratingbar kullanımı Android Tutorial animation and graphics examples Fragments fundamentals json Menu multimedia ratingbar ratingbar example ratingbar örneği ratingbar tutorial Service speech sqlite storage telephony tutorial UI widgets web service XML-
-
[:tr]Nutheme Web Site Tasarımı[:][:en]Nutheme Web Template Sonraki Makale
Konu İle İlgili Soru, Görüş ve Öneriler