<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<QuickContactBadge
android:id="@+id/quickContactBadge2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RadioButton" />
</RadioGroup>
</LinearLayout>
</ScrollView>
RatingView
ratingBar = findViewById(R.id.ratingBar);
ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float v, boolean b) {
Toast.makeText(AtyUsingRatingBar.this,"评价为:"+v , Toast.LENGTH_SHORT).show();
}
});
ImageSwitcher
private ImageSwitcher switcher;
private boolean showImg1 = true;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.aty_using_imageswitcher);
switcher = (ImageSwitcher) findViewById(R.id.imageSwitcher);
switcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
return new ImageView(AtyUsingImageSwitcher.this);
}
});
switcher.setInAnimation(AnimationUtils.loadAnimation(AtyUsingImageSwitcher.this, android.R.anim.fade_in));
switcher.setOutAnimation(AnimationUtils.loadAnimation(AtyUsingImageSwitcher.this, android.R.anim.fade_out));
switcher.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showImg1 = !showImg1;
showCurrentImage();
}
});
showCurrentImage();
}
private void showCurrentImage() {
if (showImg1) {
switcher.setImageResource(R.drawable.img1);
} else {
switcher.setImageResource(R.drawable.img2);
}
}
gallery
<Gallery
android:id="@+id/gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"></Gallery>
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1);
for (int i= 0 ; i<20 ;i++){
adapter.add("Item"+i);
}
gallery = findViewById(R.id.gallery);
gallery.setAdapter(adapter);
editText
editText = findViewById(R.id.editText)
btnGetText = findViewById(R.id.btnGetText)
btnGetText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (TextUtils.isEmpty(editText.getText())) {
Toast.makeText(AtyUsingEditText.this, "文本为空", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(AtyUsingEditText.this, editText.getText().toString(), Toast.LENGTH_SHORT).show()
}
}
})