单选 多选 拖动条 进程条 时间日期选择器

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="游泳" />

        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="读书" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <RadioGroup
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:text="男" />

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="女" />
        </RadioGroup>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <SeekBar
            android:id="@+id/id_seek_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:max="200"
            android:maxHeight="100dp"
            android:maxWidth="100dp"
            android:progress="50"/>
        <TextView
            android:id="@+id/tv_value_seekbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="0"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ProgressBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="@style/Base.TextAppearance.AppCompat.Large"/>
        <ProgressBar
            android:id="@+id/probar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
            android:progress="30"
            android:max="200"
            />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <Button
                android:id="@+id/btn_add"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="增加"/>
            <Button
                android:id="@+id/btn_reduce"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="减少"/>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <DatePicker
            android:id="@+id/dp_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:theme="@android:style/Theme"
            >

        </DatePicker>
        <TimePicker
            android:id="@+id/tp_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:theme="@android:style/Theme">

        </TimePicker>
    </LinearLayout>
</LinearLayout>

java

package com.example;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.TimePicker;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

SeekBar seekBar;
TextView textView;

ProgressBar progressBar;
DatePicker datePicker;
TimePicker timePicker;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    seekBar = (SeekBar) findViewById(R.id.id_seek_bar);
    textView = findViewById(R.id.tv_value_seekbar);

    progressBar = findViewById(R.id.probar);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            textView.setText(String.valueOf(progress));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
    findViewById(R.id.btn_add).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            progressBar.setProgress(progressBar.getProgress() + 5);
        }
    });
    findViewById(R.id.btn_reduce).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            progressBar.setProgress(progressBar.getProgress() - 5);
        }
    });

    datePicker = (DatePicker) findViewById(R.id.dp_id);
    Log.e("tag", "年份:" + datePicker.getYear());
    Log.e("tag", "月份:" + datePicker.getMonth());
    Log.e("tag", "日期:" + datePicker.getDayOfMonth());
    timePicker = findViewById(R.id.tp_id);
    Log.e("tag", "时数:"+timePicker.getHour());
    Log.e("tag", "分钟数:"+timePicker.getMinute());


}

}
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值