Actually the problem is when I click on image view of a single item its drawable is changing but many other random items have their image views changing as well with that click. Below is my code for the list adapter. I have seen the solution for this problem from some sources and I found ..
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; ..
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; ..

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 ..
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>() { ..
I have an interface that contains object types. It is also used for ViewTypes. public interface EventType { int TYPE_FROG = 1; int TYPE_STEAK = 2; int TYPE_ELEPHANT = 3; int getType(); void onBindViewHolder(RecyclerView.ViewHolder viewHolder); } And also I have three classes of data – Frog, Elephant and Steak. I display an array of all ..
I am programming a music player app and having a problem with a recyclerview inside a fragment(which connect to tablayout in my main activity) from some reason the recyclerview is not clickable and when I am pressing an item the app just close. Can you plaese help me with that? I added the fragment class ..
I have this app that I am working on and I keep getting this error when I swipe through the viewpager java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 This is where the crash point to. I have tried searching but can’t find a solution. This is how my adapter class looks like: I have a feeling it ..
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. ..
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 ..
Recent Comments