android-recyclerview

OnClickListener is not working inside my adapter class

空扰寡人 提交于 2021-01-28 19:35:40
问题 I looked at many solutions posted online but they couldn't solve my problem. Probably the adapter position is returning -1 but why? java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1 at java.util.ArrayList.get(ArrayList.java:439) at com.firebase.ui.common.BaseObservableSnapshotArray.getSnapshot(BaseObservableSnapshotArray.java:70) at com.example.twitterclone.adapters.MyAdapter$TweetViewHolder.<init>(MyAdapter.kt:36) at com.example.twitterclone.adapters.MyAdapter.onCreateViewHolder

No ripple effect on recycleview touch event

て烟熏妆下的殇ゞ 提交于 2021-01-28 15:22:47
问题 I have implemented navigation drawer using RecycleView , but when I click on items, no ripple effect shown. My device is running API 22. fragment_navigation.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"> <RelativeLayout android:id="@+id/nav_header_container" android:layout_width="match_parent" android:layout_height="140dp" android:layout

No ripple effect on recycleview touch event

做~自己de王妃 提交于 2021-01-28 15:18:20
问题 I have implemented navigation drawer using RecycleView , but when I click on items, no ripple effect shown. My device is running API 22. fragment_navigation.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"> <RelativeLayout android:id="@+id/nav_header_container" android:layout_width="match_parent" android:layout_height="140dp" android:layout

how to avoid the error OOM when displaying bitmaps in recyclerView

孤者浪人 提交于 2021-01-28 12:23:12
问题 I am trying to show bitmap images in a 3 column gridViewLayout in recyclerView. but I receive OOM (Out of Memory) exception. Note that images are picked from gallery how can I solve this problem ?? This is my onBindViewHolder : @Override public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) { final byte[] data = arrayList.get(position).getAsByteArray("byteArray"); Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); Glide.with(activity) .load

onRestoreInstanceState not working for RecyclerView layout manager if using Paging 3 library

纵饮孤独 提交于 2021-01-28 09:11:51
问题 I had a problem in saving RecyclerView state and it solved by saving layout manager state and using it after resume fragment.(thanks to @HarisDautović) class TestFragment : Fragment() { private val testListAdapter: TestListAdapter by lazy { TestListAdapter() } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { return inflater.inflate(R.layout.fragment_test, container, false) } override fun onViewCreated(view: View,

How to update RecyclerView from BroadcastReceiver?

ⅰ亾dé卋堺 提交于 2021-01-28 08:31:04
问题 In AndroidManifest.xml I have a BroadcastReceiver : <receiver android:name=".SmsMonitor"> <intent-filter android:priority="-100"> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> In my MainActivity , I have RecyclerView with a list of received SMS. My question is - How I can update the RecyclerView from my BroadcastReceiver "SmsMonitor" in case new SMS received when the application is running? UPD: I mean I need solution for both states - for

RecyclerView - changing selected item icon needs two clicks to work

落爺英雄遲暮 提交于 2021-01-28 06:08:10
问题 I am working on a mailing app, in which user can send the same mail to multiple contacts. When I open the contacts list I want to be able to click on the user and his profile picture should be replaced with checked icon. When I click to select a user the icon flickers and it does not change the first time I click on it . Second time I click on it the image still flickers, but then changes to checked , and every next time I click on that user it will flicker but do what I want - become checked

Slide image with recyclerview in full screen android

二次信任 提交于 2021-01-28 04:57:14
问题 I have create wallpaper app where I'm loading images from firebase database in recyclerview. When I click on recyclerview item(image) that item's image url sent to next activity and then that url loaded into imageView using glide. Now I want to change this to something like Image-Slider. By clicking on recyclerView item I want to show that image in full screen and also want to slide from left or right(next or previous).But I don't know how to do that. Here is my code. recyclerView

android RecyclerView BackgroundColor

爷,独闯天下 提交于 2021-01-28 03:13:00
问题 When I use RecyclerView to show list data in my app, the RecyclerView's backgroundcolor always been white: I set the backgroundcolor in xml file and code, but it does not work: //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:fitsSystemWindows="true" android:orientation="vertical" android:background="@color/colorPrimary"> <!--

Android 7 & 8 Only - ClassCastException: LayoutParams cannot be cast to AbsListView$LayoutParams

戏子无情 提交于 2021-01-27 22:46:48
问题 I have a very odd problem that I'm looking into. I didn't write the original code, but I am investigate why its crashing now, all of a sudden. After looking at it, I don't see any reason for the crash. Also, it works perfectly in lower OS levels (e.g., Android 6); however, its consistently crashing when run in Android 7 and 8. It was also very difficult to reproduce at first, because the crash only manifests after the 6th indices... Was originally thinking that it might be some corrupted data