Commit 4219dd24 by 霍志良

feat:im-灵犀2.0-单选逻辑

parent c843762f
...@@ -62,7 +62,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -62,7 +62,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion(); adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion();
for (int i=0;i<8;i++){ for (int i=0;i<8;i++){
questionList.add(new QuestionItemBean("1","婚姻情感")); questionList.add(new QuestionItemBean("1","婚姻情感",false));
} }
adapterLingxiWhichQuestion.setTagData(questionList); adapterLingxiWhichQuestion.setTagData(questionList);
adapterLingxiWhichQuestion.setItemListener(this); adapterLingxiWhichQuestion.setItemListener(this);
...@@ -86,11 +86,11 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -86,11 +86,11 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
} }
@Override @Override
public void onItemClick(@NotNull QuestionItemBean string, int position) { public void onItemClick(@NotNull QuestionItemBean itemBean, int position) {
ToastUtil.toastShort("单选点击了" + position); for (int i=0;i<questionList.size();i++){
//todo发送消息 questionList.get(i).setSelected(i==position);
}
adapterLingxiWhichQuestion.setTagData(questionList);
} }
@Override @Override
......
...@@ -5,6 +5,7 @@ import android.view.LayoutInflater ...@@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat
import com.yidianling.im.R import com.yidianling.im.R
import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
import com.yidianling.im.session.viewholder.bean.QuestionItemBean import com.yidianling.im.session.viewholder.bean.QuestionItemBean
...@@ -41,6 +42,13 @@ class AdapterLingxiWhichQuestion : RecyclerView.Adapter<AdapterLingxiWhichQuesti ...@@ -41,6 +42,13 @@ class AdapterLingxiWhichQuestion : RecyclerView.Adapter<AdapterLingxiWhichQuesti
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.tvWhichQuestion.text = tagList[position].name holder.tvWhichQuestion.text = tagList[position].name
if (tagList[position].isSelected!!){
holder.tvWhichQuestion.background=ContextCompat.getDrawable(holder.itemView.context,R.drawable.im_background_18dp_1da1f2)
holder.tvWhichQuestion.setTextColor(ContextCompat.getColor(holder.itemView.context,R.color.white))
}else{
holder.tvWhichQuestion.background=ContextCompat.getDrawable(holder.itemView.context,R.drawable.im_background_18dp_e8f5fe)
holder.tvWhichQuestion.setTextColor(ContextCompat.getColor(holder.itemView.context,R.color.platform_color_1DA1F2))
}
holder.tvWhichQuestion.setOnClickListener { holder.tvWhichQuestion.setOnClickListener {
onItemClickListener?.onItemClick( onItemClickListener?.onItemClick(
tagList[position],position) tagList[position],position)
......
...@@ -13,5 +13,6 @@ data class LingxiWhichQuestionBean( ...@@ -13,5 +13,6 @@ data class LingxiWhichQuestionBean(
) )
data class QuestionItemBean( data class QuestionItemBean(
var id:String?, var id:String?,
var name:String? var name:String?,
var isSelected: Boolean?=false
) )
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment