how to pass data between fragment and adapter? - android-recyclerview

i'm a beginner. I need help. I don't understand how access the value of seekbar in my adapter.
I want to retrieve the values ​​of the seekbars to transfer them to the adapter level in order to update the user evaluation.
I have a fragment EvalGroupFragment and the adapter EvalGroupAdapter.
I don't know how i can to access the values of the seekbars. Thanks you so much for your help.
Here is my code of my EvalGroupFragment:
class EvalGroupFragment: Fragment() {
private var custom_progress_relation: Float = 0.0f
private var custom_progress_trajets : Float = 0.0f
private var noteFinaleTrajets : Float = 0.0f
private var noteFinaleRelation : Float = 0.0f
private var _binding: FragmentEvalGroupBinding? = null
private val binding get() = _binding!!
private lateinit var mUserEvalViewModel: UserEvalViewModel
private val args by navArgs<EvalGroupFragmentArgs>()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
_binding = FragmentEvalGroupBinding.inflate(inflater, container, false)
val view = binding.root
//Recyclerview pour afficher le custom row et les données
val adapter = EvalGroupAdapter()
val recyclerView = view.findViewById<RecyclerView>(R.id.recyclerviewEvalGroup)
recyclerView?.adapter = adapter
recyclerView?.layoutManager = LinearLayoutManager(requireContext())
// UserViewModel pour afficher les données
mUserEvalViewModel = ViewModelProvider(this).get(UserEvalViewModel::class.java)
val nbTeam = args.currentUserWithEval.nbTeam
val _nbTeam = nbTeam.toString()
val gru_id = args.currentUserWithEval.gru_id_reference
mUserEvalViewModel.getGruUser(gru_id, _nbTeam).observe(
viewLifecycleOwner,
) { user ->
user.let {
adapter.setDataGroup(user)
}
}
binding.seekbarRelationGroup.setOnSeekBarChangeListener(object:
SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(
seekBar: SeekBar?,
progress: Int,
fromUser: Boolean)
{
var aFloat = progress * 0.1
custom_progress_relation = (floor(10 * aFloat + 0.5) / 10).toFloat()
noteFinaleRelation = custom_progress_relation.toFloat()
binding.noteAFL1RelationGroup.setText(custom_progress_relation.toString() + " " + " /4")
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
}
})
binding.seekbarTrajetsGroup.setOnSeekBarChangeListener(object:
SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(
seekBar: SeekBar?,
progress: Int,
fromUser: Boolean)
{
var aFloat = progress * 0.1
custom_progress_trajets = (floor(10 * aFloat + 0.5) / 10).toFloat()
noteFinaleTrajets = custom_progress_trajets.toFloat()
binding.noteAFL1TrajetsGroupGroup.setText(custom_progress_trajets.toString() + " " + " /4")
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
}
})
// Add menu
setHasOptionsMenu(true)
return view
}
private fun saveEvalInDatabase() {
val idEval = 0
note_seize = args.currentUserWithEval.note_seize
note_douze = args.currentUserWithEval.note_douze
note_relation = noteFinaleRelation.toString().trim()
note_trajets = noteFinaleTrajets.toString().trim()
note_moteur = args.currentUserWithEval.note_moteur
note_emotion = args.currentUserWithEval.note_emotion
note_afl2 = args.currentUserWithEval.note_afl2
note_afl3 = args.currentUserWithEval.note_afl3
note_sur_vingt = args.currentUserWithEval.note_sur_vingt
user_id_reference = args.currentUserWithEval.user_id_reference
val eval = Eval(idEval, note_seize, note_douze, note_relation, note_trajets, note_moteur, note_emotion, note_afl2, note_afl3, note_sur_vingt, user_id_reference)
Toast.makeText(context, eval.toString(), Toast.LENGTH_LONG).show()
mEvalViewModel.updateEval(eval)
}
private fun clicSound() {
val mediaPlayer: MediaPlayer = MediaPlayer.create(context, R.raw.select_click)
mediaPlayer.start()
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.delete_menu, menu)
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
and here is my code of my adapter: EvalGroupAdapter
class EvalGroupAdapter: RecyclerView.Adapter<EvalGroupAdapter.MyViewHolder>() {
var userList = emptyList<UserWithEval>()
class MyViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.custom_group_details, parent, false))
}
override fun getItemCount(): Int {
return userList.size
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val currentItemEvalGroup = userList[position]
holder.itemView.findViewById<TextView>(R.id.lastName_txt_details).text = currentItemEvalGroup.lastName.uppercase()
holder.itemView.findViewById<TextView>(R.id.firstName_txt_details).text = currentItemEvalGroup.firstName.uppercase()
holder.itemView.findViewById<TextView>(R.id.numeroTeam_txt_details).text = currentItemEvalGroup.nbTeam.uppercase()
}
fun setDataGroup(user: List<UserWithEval>){
this.userList = user
notifyDataSetChanged()
}
}
and here is my recyclerview:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2sp"
android:layout_marginTop="30dp"
android:background="#drawable/row_add_user"
android:id="#+id/rowLayoutDetails">
<TextView
android:id="#+id/lastName_txt_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nom"
android:layout_marginLeft="120dp"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/firstName_txt_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="Prénom"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#+id/lastName_txt_details"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/numeroTeam_txt_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="(2)"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#+id/firstName_txt_details"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/btn_confirmation_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:background="#drawable/rectangle_titre"
android:text="SAVE"
android:textSize="25sp"
app:layout_constraintBottom_toBottomOf="#+id/lastName_txt_details"
app:layout_constraintStart_toEndOf="#+id/numeroTeam_txt_details"
app:layout_constraintTop_toTopOf="#+id/lastName_txt_details" />
</androidx.constraintlayout.widget.ConstraintLayout>
and my fragment_eval_group xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/linear_gradient_bg"
android:orientation="horizontal"
android:id="#+id/fragEvalGroup">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerviewEvalGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:id="#+id/linear_afl1_relation_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="250dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view_v_1">
<TextView
<LinearLayout
android:id="#+id/linear_seekbar_relation_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableau_relation_group">
<SeekBar
android:id="#+id/seekbar_relation_group"
android:layout_width="700dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:max="40"
android:min="0"
android:progress="0"
android:progressDrawable="#drawable/custom_seekbar"
android:thumb="#drawable/custom_thumb" />
</LinearLayout>
<com.google.android.material.divider.MaterialDivider
android:id="#+id/divider_relation_trajets_group"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
app:dividerColor="#color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linear_seekbar_relation_group" />
//FIN LINEAR AFL1 RELATION
//LINEAR AFL1 TRAJETS
<LinearLayout
android:id="#+id/linear_afl1_trajets_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/divider_relation_trajets_group">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:background="#drawable/rectangle_titre"
android:padding="10dp"
android:text="Trajets"
android:textColor="#23203D"
android:textSize="22sp"
android:textStyle="bold" />
<Space
android:layout_width="300dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/noteAFL1_TrajetsGroup_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/custom_input_eval"
android:gravity="center_horizontal"
android:padding="5dp"
android:text=" /4"
android:textAlignment="center"
android:textColor="#23203D"
android:textSize="#dimen/size_note" />
</LinearLayout>
<LinearLayout
android:id="#+id/tableau_trajets_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linear_afl1_trajets_group">
<TableLayout
android:id="#+id/table_Trajets_group"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:stretchColumns="0,2, 4 , 6">
<TableRow
android:id="#+id/firstRowTrajets"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- first element of the row-->
<TextView
android:id="#+id/simpleTextView1Trajets"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#99FADF16"
android:gravity="right"
android:padding="18dip"
android:text="0 0.5"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/simpleTextView3Trajets"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#99A99EFF"
android:gravity="center"
android:padding="18dip"
android:text="0.5 1 2"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/simpleTextView5Trajets"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#99FA6148"
android:gravity="center"
android:padding="18dip"
android:text="2 2.5 3"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/simpleTextView7Trajets"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#99FCEC83"
android:gravity="left"
android:padding="18dip"
android:text="3 4"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold" />
</TableRow>
<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="1dp"
app:dividerColor="#color/black" />
<TableRow
android:id="#+id/secondRowTrajets_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_span="1"
android:background="#99FADF16"
android:gravity="center"
android:text=" - Choré. statique \n - Trajets en Aller-Retour \n - Pas de sol "
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_span="1"
android:background="#99BAFA16"
android:gravity="center"
android:text=" - Faible utilisation de \n l'espace scénique \n - Passage au sol \n et redressement maladroit"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_span="1"
android:background="#99FA6148"
android:gravity="center"
android:text=" - Bonne utilisation de \n l'espace scénique \n - Utilisation du sol"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_span="1"
android:background="#99FCEC83"
android:gravity="center"
android:text=" - Très bonne utilisation \n de l'espace scénique\n - Trajets riches et variés \n - Le sol sert le propos"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linear_seekbar_trajets_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableau_trajets_group">
<SeekBar
android:id="#+id/seekbar_trajets_group"
android:layout_width="700dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:max="40"
android:min="0"
android:progress="0"
android:progressDrawable="#drawable/custom_seekbar"
android:thumb="#drawable/custom_thumb" />
</LinearLayout>
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linear_seekbar_trajets_group">
<Button
android:id="#+id/btn_confirmation_eval_group"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="SAVE"
android:textSize="30sp"
android:textStyle="bold"
android:background="#drawable/rectangle_1"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Related

Custom Listview whole row is not selected in Dialog Fragment in kotlin using viewbinding

Data Set custom listview in Dialog Fragment using BaseAdapter. when select list item then only text item selected, whole row is not selected.
CustomDialog.kt
class CustomDialog(val servList: ArrayList<Serve>) : DialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val inflater = context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val binding = DialogListViewBinding.inflate(inflater)
val builder = AlertDialog.Builder(requireContext())
val servAdapter = DialogListAdapter(servList, requireContext())
binding.listViewDialog.adapter = servAdapter
servAdapter.notifyDataSetChanged()
val dialog = builder.create()
dialog.show()
binding.listViewDialog.isClickable = true
binding.listViewDialog.setOnItemClickListener { adapterView, view, i, l ->
val serve = adapterView.getItemAtPosition(i) as Serve
val serve1 = serve.serveNo
dialog.dismiss()
/* (activity as AddProduct?)..setText(input)*/
mOnInputListener?.sendInput(serve1.toString())
Toast.makeText(requireContext(), serve1.toString(), Toast.LENGTH_LONG).show()
}
return binding.root
}
DialogListAdapter.kt
class DialogListAdapter (val servNo : ArrayList<Serve>,val context: Context) : BaseAdapter() {
override fun getCount(): Int {
return servNo.size
}
override fun getItem(p0: Int): Serve = servNo[p0]
override fun getItemId(p0: Int): Long {
return p0.toLong()
}
override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val binding = DialogListItemBinding.inflate(inflater)
val ser = servNo.get(p0)
binding.tvListViewDialogItem.text = ser.serveNo
return binding.root
}
}
dialog_list_view.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="#FFD700"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<!-- android:background="#FFD700"-->
<!--android:background="#color/dark_green"-->
<ImageView
android:id="#+id/imgDialogListClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="9dp"
android:src="#drawable/ic_clear_black_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/tvDialogListTitle"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvDialogListTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="Select Serve No"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/imgDialogListClear"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ListView
android:id="#+id/listViewDialog"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/constraintLayout"/>
</androidx.constraintlayout.widget.ConstraintLayout>
dialog_list_item.xml
[![<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/tvListViewDialogItem"
android:gravity="center"
android:padding="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Above Image Listview item selected second item only text item part selected in yellow border. Green border part is not selected, so list item whole row is not selected. how to its selected?

The addOnScrollListener for my RecyclerView not working as expected

I want to know when I am at the bottom of my recycler view but I can't get why the recyclerView.canScrollVertically(1) is always returning true even if I am at the bottom of the Recycler View.
The recycler view is inside a CoordinatorLayout with an AppBarLayout.
You have the Kotlin code and the XML code for the bigger picture
Thank you.
getDataBinding().shipmentRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
Log.e(TAG,
"onScrollStateChanged 1: This is the bottom shipmentRecyclerView $newState <> ${RecyclerView.SCROLL_STATE_IDLE} ${
recyclerView.canScrollVertically(1)
}")
if (!getDataBinding().shipmentRecyclerView.canScrollVertically(1) && newState == RecyclerView.SCROLL_STATE_IDLE) {
Log.e(TAG, "onScrollStateChanged 2: This is the bottom shipmentRecyclerView")
if (viewModel.currentPage.get()!! < viewModel.totalPages.get()!!) {
viewModel.getShipmentByPage(
viewModel.currentPage.get()!! + 1,
viewModel.request.get()
)
}
}
}
})
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="com.technifyit.jibheli.presentation.main.fragment.search.SearchViewModel" />
</data>
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
app:umanoPanelHeight="0dp"
app:umanoShadowHeight="#dimen/margin_4dp"
tools:context=".presentation.main.fragment.search.SearchFragment">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/shipment_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/margin_12dp"
android:clipToPadding="true"
android:fastScrollEnabled="true"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:shipment_adapter="#{viewModel}" />
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/dark_color_purple"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
...........
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/dark_color_purple"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:visibility="gone"
app:contentInsetStart="0dp"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom"
app:layout_collapseMode="pin"
app:theme="#style/ThemeOverlay.AppCompat.Dark"
app:title="">
.........
</androidx.appcompat.widget.Toolbar>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/custom_web_page_browser"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/margin_40dp"
android:background="#drawable/background_rounded_top"
android:backgroundTint="#color/grey_clair">
<com.technifyit.jibheli.presentation.customView.MontserratBoldTextView
android:id="#+id/url_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_20dp"
android:layout_marginEnd="#dimen/margin_6dp"
android:text="#string/activity_item_details_send_request_button_text"
android:textColor="#color/dark_color_purple"
android:textSize="#dimen/title_size_sign_up"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#id/close"
app:layout_constraintEnd_toStartOf="#id/use_link_image_view"
app:layout_constraintStart_toEndOf="#id/close"
app:layout_constraintTop_toTopOf="#id/close" />
<ImageView
android:id="#+id/close"
android:layout_width="#dimen/icon_24dp"
android:layout_height="#dimen/icon_24dp"
android:layout_margin="#dimen/margin_6dp"
android:background="#drawable/ic_close_gold"
android:backgroundTint="#color/dark_color_purple"
android:padding="#dimen/margin_4dp"
android:src="#drawable/ic_close_native"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="#color/white" />
<com.technifyit.jibheli.presentation.customView.MontserratBoldTextView
android:id="#+id/use_link_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_6dp"
android:background="#drawable/button_rounded_left_only_no_icon"
android:backgroundTint="#color/dark_color_purple"
android:drawableEnd="#drawable/ic_check_native"
android:drawablePadding="#dimen/margin_6dp"
android:gravity="center"
android:paddingStart="#dimen/margin_8dp"
android:paddingEnd="#dimen/margin_8dp"
android:text="#string/select"
android:textAllCaps="false"
android:textColor="#color/white"
app:drawableTint="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="#dimen/margin_4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/close">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="#+id/no_item_found_suggested_layout"
layout="#layout/no_item_found_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/requested_shipments_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_6dp"
android:fastScrollEnabled="true"
app:layout_constraintTop_toTopOf="parent"
app:requested_shipment_adapter="#{viewModel}" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/requested_trip_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_6dp"
android:fastScrollEnabled="true"
app:layout_constraintTop_toTopOf="parent"
app:requested_trip_adapter="#{viewModel}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</layout>
Thank you for your response, i did find a solution by adding to my recycler view in xml
addOnScrolledToBottomListener="#{viewModel}" and then in the bindingAdapter
#BindingAdapter("addOnScrolledToBottomListener")
fun addOnScrolledToBottomListener(recyclerView: RecyclerView, viewModel: SearchViewModel) {
recyclerView.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (recyclerView.canScrollVertically(1) && newState == RecyclerView.SCROLL_STATE_IDLE) {
if (viewModel.currentPage.get()!! < viewModel.totalPages.get()!!) {
viewModel.getShipmentByPage(
viewModel.currentPage.get()!! + 1,
viewModel.request.get()
)
}
}
}
})
}`
and like that it worked like a charm, Thank you #xinaiz for your help

MaterialCardView not showing when added programmatically

I am not able to see MaterialViewCard at my Activity when adding programmatically. If I add directly on XML, it shows. But When adding via Kotling, it doesn't.
XML sample:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SecondFragment">
<LinearLayout
android:id="#+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<LinearLayout
android:id="#+id/layout_first_block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.card.MaterialCardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/surface"
android:layout_margin="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:textColor="#color/on_surface"/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/surface"
android:layout_margin="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01"
android:textColor="#color/on_surface"/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/surface"
android:layout_margin="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="03"
android:textColor="#color/on_surface"/>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_weight="1">
<Button
android:id="#+id/button_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/previous"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Result:
Cards added via XML
But when I try this (below) won't work.
XML:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SecondFragment">
<LinearLayout
android:id="#+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<LinearLayout
android:id="#+id/layout_first_block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<!-- Will add here-->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_weight="1">
<Button
android:id="#+id/button_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/previous"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Kotlin:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.findViewById<Button>(R.id.button_second).setOnClickListener {
findNavController().navigate(R.id.action_SecondFragment_to_FirstFragment)
}
val layoutFirstBlock: LinearLayout = view.findViewById<LinearLayout>(R.id.layout_first_block)
for (r in 1..10){
val row: LinearLayout = LinearLayout(context)
row.orientation = LinearLayout.HORIZONTAL
row.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
for(c in 1..10){
val card: MaterialCardView = MaterialCardView(context)
val marginParams: ViewGroup.MarginLayoutParams = ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
marginParams.setMargins(R.dimen.small_padding, R.dimen.small_padding, R.dimen.small_padding, R.dimen.small_padding)
card.layoutParams = marginParams
card.setBackgroundColor(resources.getColor(R.color.surface, context?.theme))
val num: TextView = TextView(context)
num.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
val value = ((r-1)*10 + c).toString()
num.text = value
num.setTextColor(resources.getColor(R.color.on_surface, context?.theme))
Log.d("i", "i$r$c = $value")
card.addView(num)
row.addView(card)
}
layoutFirstBlock.addView(row, 0)
}
}
Result: Cards missing when added by Kotlin
Any ideas?
Thanks!
In my case the issue was i have a component above the cardview and i have set its height to match_parent,when i gave the height to wrap_content the issue has been solved.
If it doesn't work also check in build gradle for below line.
implementation 'com.google.android.material:material:1.0.0'
Firstly,
You need to generate id's of each view as well.
val card: MaterialCardView = MaterialCardView(context)
card.id = View.generateViewId()
and
val num: TextView = TextView(context)
num.id = View.generateViewId()
Secondly,
I think, you should need to update index of
layoutFirstBlock.addView(row, 0)
to
layoutFirstBlock.addView(row, r)

GridView cannot be cast to ViewPager in Kotlin Custom Calendar

Working on the custom calendar in Kotlin.
On tapping the DateText, this custom calendar widget will be opened in a new fragment.
I used Grid Views to display the dates and I'm getting ClassCastException on navigating to the Calendar Screen(GridView cannot be cast to ViewPager).
Error:
Caused by: java.lang.ClassCastException: com.daimler.myfinance.payment.paymentdate.extensions.CalendarGridView cannot be cast to com.daimler.myfinance.payment.paymentdate.extensions.CalendarViewPager
at com.payment.paymentdate.CalendarView.initUiElements(CalendarView.kt)
CalendarView.kt
open class CalendarView : LinearLayout {
private var mViewPager: CalendarViewPager? = null
private fun initUiElements() {
mViewPager = findViewById<ViewPager>(R.id.calendarViewPager) as CalendarViewPager
}
}
CalendarViewPager.kt
class CalendarViewPager : ViewPager {
constructor(context: Context?) : super(context!!) {
}
constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs) {
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
var heightMeasureSpec = heightMeasureSpec
var height = 0
for (i in 0 until getChildCount()) {
val child: View = getChildAt(i)
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED))
val h = child.measuredHeight
if (h > height) {
height = h
}
}
if (height != 0) {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
}
}
calendar_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<!-- date toolbar -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/calendarHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/jumio_white"
app:layout_constraintBottom_toTopOf="#+id/abbreviationsBar">
<ImageButton
android:id="#+id/previousButton"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="30dp"
android:layout_height="match_parent"
android:src="#drawable/ic_chevron_left"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.uikit.widgets.textviews.MBBody2TextView
android:id="#+id/currentDateLabel"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:gravity="center"
android:textColor="#color/jumio_black"
android:textSize="18sp"
app:layout_constraintLeft_toRightOf="#id/previousButton"
app:layout_constraintRight_toLeftOf="#id/forwardButton"
app:layout_constraintTop_toTopOf="parent"
android:text="April 2020" />
<ImageButton
android:id="#+id/forwardButton"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="30dp"
android:layout_height="match_parent"
android:src="#drawable/ic_chevron_right"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- eventDays header -->
<LinearLayout
android:id="#+id/abbreviationsBar"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="#+id/calendarHeader">
<com.\uikit.widgets.textviews.MBBody2TextView
android:id="#+id/mondayLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="#string/material_calendar_monday"
android:textColor="#color/jumio_black" />
<com.uikit.widgets.textviews.MBBody2TextView
android:id="#+id/tuesdayLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="#string/material_calendar_tuesday"
android:textColor="#color/jumio_black" />
<com.uikit.widgets.textviews.MBBody2TextView
android:id="#+id/wednesdayLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="#string/material_calendar_wednesday"
android:textColor="#color/jumio_black" />
<com.uikit.widgets.textviews.MBBody2TextView
android:id="#+id/thursdayLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="#string/material_calendar_thursday"
android:textColor="#color/jumio_black" />
<com.uikit.widgets.textviews.MBBody2TextView
android:id="#+id/fridayLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="#string/material_calendar_friday"
android:textColor="#color/jumio_black" />
<com.uikit.widgets.textviews.MBBody2TextView
android:id="#+id/saturdayLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="#string/material_calendar_saturday"
android:textColor="#color/jumio_black" />
<com.uikit.widgets.textviews.MBBody2TextView
android:id="#+id/sundayLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="#string/material_calendar_sunday"
android:textColor="#color/jumio_black" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/gridScroll"
app:layout_constraintTop_toBottomOf="#+id/abbreviationsBar">
<com.payment.paymentdate.extensions.CalendarGridView
android:id="#+id/calendarViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
</LinearLayout>
Because in your xml you have defined com.payment.paymentdate.extensions.CalendarGridView which is subclassof GridView and you are assigning it to ViewPager wich is type of ViewPager
<com.payment.paymentdate.extensions.CalendarViewPager
android:id="#+id/calendarViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

why my submodel cannot be cast to java.util.ArrayList

I'm making a recyclerview with multilevel data, and there is a problem when entering data into the sub-adapter. appear error like this "model cannot be cast to java.util.ArrayList android"
my json
[{
"header" : "buah air",
"sub" : {
"warna" : "merah",
"jenis" : "air"
}
},{
"header" : "buah serat",
"sub" : {
"warna" : "hijau",
"jenis" : "serat"
}
}]
my model
data class mTOP (
val header : String,
#SerializedName("sub") val sub : mSubTOP
)
data class mSubTOP(
val warna : String,
val jenis : String
)
my MainActivity
val adapter = adapter_top(response!!.body() as ArrayList<mTOP>)
rv.adapter = adapter
my adapter_top (here an error occurs)
override fun onBindViewHolder(holder: adapter_top.ViewHolder, position: Int) {
holder.tvHeader?.text = Datane[position].header
holder.rvList?.layoutManager = LinearLayoutManager(holder.rvList.context, LinearLayout.VERTICAL, false)
var adapterSub = adapter_sub(Datane[position].sub as ArrayList<mSubTOP>)
holder.rvList?.adapter = adapterSub
}
my adapter_sub
class adapter_sub(val Datane: ArrayList<mSubTOP>): RecyclerView.Adapter<adapter_sub.ViewHolder>() {
}
Because it's not ArrayList at all :) You have to create a list with one element:
adapter_sub(arrayListOf(Datane[position].sub))
this complete my adapter_sub
class adapter_sub(val Datane: ArrayList<mSubTOP>): RecyclerView.Adapter<adapter_sub.ViewHolder>() {
override fun onBindViewHolder(holder: adapter_sub.ViewHolder, position: Int) {
val location = Datane[position]
holder.tvName?.text = location.warna
holder.tvHobi?.text = location.jenis
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): adapter_sub.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.layout_sub, parent, false)
return ViewHolder(v)
}
override fun getItemCount(): Int {
return Datane.size
}
class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
val tvName = itemView.findViewById<TextView>(R.id.tvJenis)
val tvHobi = itemView.findViewById<TextView>(R.id.tvWarna)
}
}
layout activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/RvMain"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" >
</androidx.recyclerview.widget.RecyclerView>
</androidx.constraintlayout.widget.ConstraintLayout>
layout layout_top.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:gravity="center_vertical"
android:text="Date"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Large"
android:textColor="#009688"
android:textSize="18sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
layout layout_sub.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:id="#+id/locationBadge"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#drawable/circle_badge"
android:gravity="center_vertical|center_horizontal"
android:text="✓"
android:textColor="#fff"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/tvWarna"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Name"
android:textSize="18sp" />
<TextView
android:id="#+id/tvJenis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Address"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
this my stack trace
10-20 06:24:08.445 11624-11624/br.com.mirabilis.jambu_air E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.mirabilis.jambu_air, PID: 11624
android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class TextView
at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at br.com.mirabilis.jambu_air.adapter.adapter_sub.onCreateViewHolder(adapter_sub.kt:23)
at br.com.mirabilis.jambu_air.adapter.adapter_sub.onCreateViewHolder(adapter_sub.kt:13)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3336)
at android.view.View.measure(View.java:18811)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18811)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at androidx.cardview.widget.CardView.onMeasure(CardView.java:260)
at android.view.View.measure(View.java:18811)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18811)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:9119)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1583)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:444)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.LinearLayout.setCh
10-20 06:24:08.448 11624-11624/br.com.mirabilis.jambu_air E/MQSEventManagerDelegate: failed to get MQSService.
10-20 06:24:08.473 11624-11624/br.com.mirabilis.jambu_air I/Process: Sending signal. PID: 11624 SIG: 9