public class NextActivity extends AppCompatActivity {
ToggleButton toggleButton;
ImageView imageView;
RatingBar ratingBar;
Button button;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next_layout);
toggleButton=(ToggleButton)findViewById(R.id.toggleButton);
imageView=(ImageView)findViewById(R.id.imageView);
ratingBar=(RatingBar)findViewById(R.id.ratingBar);
button=(Button)findViewById(R.id.button3);
toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(getApplicationContext(),"Button on action",Toast.LENGTH_SHORT).show();
if(isChecked){
imageView.setVisibility(View.VISIBLE);
}else{
imageView.setVisibility(View.INVISIBLE);
}
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String value=String.valueOf(ratingBar.getRating());
Toast.makeText(getApplicationContext(),value,Toast.LENGTH_LONG).show();
}
});
}
}
No comments:
Post a Comment