Category : adapter

I have a listview with a adapter, the listview items are linarlayout with switches containing random numbers, how can write a click listener for the switches? activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:id="@+id/lster" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp"> </ListView> </LinearLayout> MainActivity.java package com.kattah.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import android.widget.Toast; import java.util.ArrayList; ..

Read more

I have a listview with a adapter, the listview items are linarlayout with switches containing random numbers, how can write a click listener for the switches? activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:id="@+id/lster" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp"> </ListView> </LinearLayout> MainActivity.java package com.kattah.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import android.widget.Toast; import java.util.ArrayList; ..

Read more

I have a parameterized base class @JsonClass(generateAdapter = true) data class BaseResponse<T>( @Json(name = "message") val message: String?, @Json(name = "data") val data: T? = null ) I want to get parse a JSON string and get the message value private inline fun <reified T> getMessage(): String? { return try { val jsonStr = "{"message":"Email ..

Read more

I created a RecyclerView Adapter using databinding and I’m trying to handle Click events inside this adapter but I don’t know exactly how. I found different topics but couldn’t solve my problem yet. Thanks! Where should I implement (inside the Adapter class) the onClick function? Adapter Class class RemovableContactsAdapter(val viewModel: GroupDetailsViewModel,val callback:GroupContactsCallback) : RecyclerView.Adapter<RemovableContactsViewHolder>() { ..

Read more

This is my code, and unfortunately it does not give me the option to set an adapter, why not? public class MainActivity2 extends AppCompatActivity { private database mydb ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); mydb = new database(this); } ArrayList<String> rs= mydb.getEveryone(); ListView listView = findViewById(R.id.lv_customerList); ArrayAdapter adapter = new ArrayAdapter<String>(this,R.layout.activity_main2,R.id.textView,rs); listView. ..

Read more

I read this but could not find the answer. I simply want to add Fragment when any item from listView is clicked. I tried to access getSupportFragmentManager to implement Fragment but couldn’t access it. I instantiated FragmentActivity class and then called supportFragmentManager. Now facing above following error. java.lang.IllegalStateException: FragmentManager has not been attached to a ..

Read more