图像视图中的 Recryler 如何使不可见
Recryler in imageview how to make invisible
如何解决这个问题?
我想在 Imageview 中 recylerview make INVISIBLE 但它不起作用
我的代码在下面
对不起我的英语不好:)
这个动静在很多地方都找不到出处
class CevaplarRecylerAdapter(
private val username: ArrayList<String>,
private val comment: ArrayList<String>,
)
:RecyclerView.Adapter<CevaplarRecylerAdapter.ViewHolder>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): CevaplarRecylerAdapter.ViewHolder {
val inflater=LayoutInflater.from(parent.context)
val view =inflater.inflate(R.layout.answer_layout, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: CevaplarRecylerAdapter.ViewHolder, position: Int) {
holder.UsernameText?.text=username[position]
holder.LoadAnswerText?.text=comment[position]
}
override fun getItemCount(): Int {
return username.size
}
inner class ViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){
var UsernameText:TextView?=null
var LoadAnswerText:TextView?=null
@SuppressLint("ResourceType")
var kontrol:ImageView=itemView.findViewById(R.drawable.cevap)
init {
LoadAnswerText=itemView.findViewById(R.id.LoadAnswerTexttv)
UsernameText=itemView.findViewById(R.id.UsernameTexttv)
kontrol.visibility = View.INVISIBLE; // ı want to this view make Invisiable
}
}
interface OnItemClickListener {
}
}
在你的 ViewHolder
中找到你的 imageView 的 id 而不是 drawable
更改此行
@SuppressLint("ResourceType")
var kontrol:ImageView=itemView.findViewById(R.drawable.cevap)
至
var kontrol:ImageView=itemView.findViewById(R.id.yourImageViewId)
找到了
class CevaplarRecylerAdapter(
private val username: ArrayList<String>,
private val comment: ArrayList<String>,
private val check:Boolean
)
:RecyclerView.Adapter<CevaplarRecylerAdapter.ViewHolder>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): CevaplarRecylerAdapter.ViewHolder {
val inflater=LayoutInflater.from(parent.context)
val view =inflater.inflate(R.layout.answer_layout, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: CevaplarRecylerAdapter.ViewHolder, position: Int) {
holder.UsernameText?.text=username[position]
holder.LoadAnswerText?.text=comment[position]
var a=true
if (a==true){
Picasso.get().load("https://firebasestorage.googleapis.com/v0/b/egitimnoktasilast.appspot.com/o/images%2F06b57525-0f40-4f86-9fae-8dc6082aab7e.jpg?alt=media&token=5183e857-2252-48b3-bbca-f96a0517ddce").into(holder.photo)
}
}
override fun getItemCount(): Int {
return username.size
}
inner class ViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){
var UsernameText:TextView?=null
var LoadAnswerText:TextView?=null
var photo:ImageView?=null
init {
LoadAnswerText=itemView.findViewById(R.id.LoadAnswerTexttv)
UsernameText=itemView.findViewById(R.id.UsernameTexttv)
photo=itemView.findViewById(R.id.Rightimage)
Visibility(check)
}
fun Visibility(check: Boolean){
if (check==true){
photo!!.visibility=View.VISIBLE
}
else{
photo!!.visibility=View.INVISIBLE
}
}
}
interface OnItemClickListener {
}
}
您需要在 drawable 的位置添加 imageview 的 id,如下所示 -
替换这个
var kontrol:ImageView=itemView.findViewById(R.drawable.cevap)
有了这个
var kontrol:ImageView=itemView.findViewById(R.id.yourimageviewid)
如何解决这个问题? 我想在 Imageview 中 recylerview make INVISIBLE 但它不起作用 我的代码在下面 对不起我的英语不好:) 这个动静在很多地方都找不到出处
class CevaplarRecylerAdapter(
private val username: ArrayList<String>,
private val comment: ArrayList<String>,
)
:RecyclerView.Adapter<CevaplarRecylerAdapter.ViewHolder>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): CevaplarRecylerAdapter.ViewHolder {
val inflater=LayoutInflater.from(parent.context)
val view =inflater.inflate(R.layout.answer_layout, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: CevaplarRecylerAdapter.ViewHolder, position: Int) {
holder.UsernameText?.text=username[position]
holder.LoadAnswerText?.text=comment[position]
}
override fun getItemCount(): Int {
return username.size
}
inner class ViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){
var UsernameText:TextView?=null
var LoadAnswerText:TextView?=null
@SuppressLint("ResourceType")
var kontrol:ImageView=itemView.findViewById(R.drawable.cevap)
init {
LoadAnswerText=itemView.findViewById(R.id.LoadAnswerTexttv)
UsernameText=itemView.findViewById(R.id.UsernameTexttv)
kontrol.visibility = View.INVISIBLE; // ı want to this view make Invisiable
}
}
interface OnItemClickListener {
}
}
在你的 ViewHolder
中找到你的 imageView 的 id 而不是 drawable
更改此行
@SuppressLint("ResourceType")
var kontrol:ImageView=itemView.findViewById(R.drawable.cevap)
至
var kontrol:ImageView=itemView.findViewById(R.id.yourImageViewId)
找到了
class CevaplarRecylerAdapter(
private val username: ArrayList<String>,
private val comment: ArrayList<String>,
private val check:Boolean
)
:RecyclerView.Adapter<CevaplarRecylerAdapter.ViewHolder>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): CevaplarRecylerAdapter.ViewHolder {
val inflater=LayoutInflater.from(parent.context)
val view =inflater.inflate(R.layout.answer_layout, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: CevaplarRecylerAdapter.ViewHolder, position: Int) {
holder.UsernameText?.text=username[position]
holder.LoadAnswerText?.text=comment[position]
var a=true
if (a==true){
Picasso.get().load("https://firebasestorage.googleapis.com/v0/b/egitimnoktasilast.appspot.com/o/images%2F06b57525-0f40-4f86-9fae-8dc6082aab7e.jpg?alt=media&token=5183e857-2252-48b3-bbca-f96a0517ddce").into(holder.photo)
}
}
override fun getItemCount(): Int {
return username.size
}
inner class ViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){
var UsernameText:TextView?=null
var LoadAnswerText:TextView?=null
var photo:ImageView?=null
init {
LoadAnswerText=itemView.findViewById(R.id.LoadAnswerTexttv)
UsernameText=itemView.findViewById(R.id.UsernameTexttv)
photo=itemView.findViewById(R.id.Rightimage)
Visibility(check)
}
fun Visibility(check: Boolean){
if (check==true){
photo!!.visibility=View.VISIBLE
}
else{
photo!!.visibility=View.INVISIBLE
}
}
}
interface OnItemClickListener {
}
}
您需要在 drawable 的位置添加 imageview 的 id,如下所示 -
替换这个
var kontrol:ImageView=itemView.findViewById(R.drawable.cevap)
有了这个
var kontrol:ImageView=itemView.findViewById(R.id.yourimageviewid)