<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RatingBar
android:id="@+id/ratingBar2"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="10"
android:stepSize="1" />
<RatingBar
android:id="@+id/ratingBar3"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rating="1.5"/>
<Button
android:id="@+id/btnInc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="증가시키기" />
<Button
android:id="@+id/btnDec"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="감소시키기" />
</LinearLayout>
package com.example.it.myapplication8_3;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RatingBar;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RatingBar rating1, rating2, rating3;
Button btnInc, btnDec;
rating1 = (RatingBar) findViewById(R.id.ratingBar1);
rating2 = (RatingBar) findViewById(R.id.ratingBar2);
rating3 = (RatingBar) findViewById(R.id.ratingBar3);
btnInc = (Button) findViewById(R.id.btnInc);
btnDec = (Button) findViewById(R.id.btnDec);
btnInc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rating1.setRating(rating1.getRating() + rating1.getStepSize());
rating2.setRating(rating2.getRating() + rating2.getStepSize());
rating3.setRating(rating3.getRating() + rating3.getStepSize());
}
});
btnDec.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rating1.setRating(rating1.getRating() - rating1.getStepSize());
rating2.setRating(rating2.getRating() - rating2.getStepSize());
rating3.setRating(rating3.getRating() - rating3.getStepSize());
}
});
}
}
android - 양방향 intent (0) |
2018.09.24 |
android - 투표 최대결과 인텐트 전환하며 값 넘겨주기 (Activity, Intent, putExtra, getIntent, getIntArrayExtra, getStringArrayExtra) (0) |
2018.09.23 |
android - Activity, Intent 응용 (액티비티 화면 세개 전환) (0) |
2018.09.22 |
android - Activity, Intent (0) |
2018.09.22 |
android - AlertDialog, setPositiveButton, setNegativeButton, Toast (0) |
2018.09.22 |