一、需求
1.ratingbar、Android-PickerView的使用
2.点击复制控件文字,以及字符串拼接
二、实现步骤
1.依赖
implementation 'com.github.giswangsj:AndRatingBar:v1.0.0'
implementation 'com.contrarywind:Android-PickerView:4.1.9'
2.给ratingbar换图标,自定义PickerView的样式
app:starDrawable="@mipmap/ico_water_on"
app:bgDrawable="@mipmap/ico_water"
app:starColor="@color/color_new_pink"
ll_setting_keep.setOnClickListener {
val pickKeepDay = OptionsPickerBuilder(
this
) { i1, _, _, _ ->
val tx: String = ("${keepDayList[i1]}天")
tv_menstruation_keep_day.text = tx
// Toast.makeText(this@FillInformationActivity, tx, Toast.LENGTH_SHORT).show()
}
.setCancelColor(ContextCompat.getColor(this,R.color.color_new_pink))
.setSubmitColor(ContextCompat.getColor(this,R.color.color_new_pink))
.setTitleColor(ContextCompat.getColor(this,R.color.black))
.setTitleText(resources.getString(R.string.pick_keep_day))
.build<Int>()
pickKeepDay.setPicker(keepDayList)
pickKeepDay.setSelectOptions(4)
pickKeepDay.show()
}
点击复制控件文字
copyTextToBoard(mContext!!,tv_email_detail.text.toString())
String内字符串拼接
getString(R.string.welcome_message, getString(R.string.name))
<string name="welcome_message">欢迎使用%s,时刻关注自己的日常活动</string>
<string name="name">你的名字</string>