android-recyclerview

Android Studio Delete Items from Recycler View and List [duplicate]

≡放荡痞女 提交于 2021-02-11 14:45:26
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 10 months ago . I am trying to remove a specific item when I click on it. I have run logs so I know that it's picking an item I just don't understand what the error means. If it is important I am using room database and using a recycler view. java.lang.NullPointerException: Attempt to invoke virtual method 'void uk.edu.le.co2103.myrecipebook.RecipeListAdapter.notifyItemRemoved(int

How can I detect recycling from within a recyclerView adapter, so I can perform an action before it gets recycled?

为君一笑 提交于 2021-02-11 14:40:50
问题 I have a recyclerview that contains fields with editTexts . When scrolling, the data in the edit texts gets all mixed up or erased due to some functions I use and the views being recycled. This could be completely solved if I could save my data before the view gets recycled. How can I detect that happening from WITHIN the adapter? 回答1: Just add below code in your adapter's onBindViewHolder method: viewHolder.setIsRecyclable(false); so you never lose your data on the scroll. 回答2: The

How do I handle my data model class to get Firebase Firestore data into recyclerView?

寵の児 提交于 2021-02-11 14:34:05
问题 I have a Firestore database like this: I want to access each of the different symptom data's i.e. "Anxiety_data" and its children which consists of timestamps, and then a dictionary, and place them into a RecyclerView using FirebaseUI FirebaseRecyclerViewAdapter I have this model class: public class EntryDataModel { private String timestamp, symptom, severity, comment; public EntryDataModel() {} public EntryDataModel(String timestamp, String symptom, String severity, String comment) { this

Can't pass null for argument 'pathString' in child()? This the error I'm getting when retrieving data from firebase

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 12:28:20
问题 I'm creating an app with firebase as a backend, First I got output but after few changes I did for intent then it shows like this, Can anyone help me to solve this error. I used if to check whether I'm getting data or not and It goes through that if condition still it shows null. Activity 1: public class centerActivity extends AppCompatActivity { RecyclerView recyclerView; ArrayList<data> mArrayList; FrontlistAdapter mAdapter; FirebaseRecyclerOptions<data> options; FirebaseDatabase database =

how to distribute items inside recycle-view evenly?

♀尐吖头ヾ 提交于 2021-02-10 18:17:30
问题 i Have recycle view as follow: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorWhite" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical|center_horizontal" android:textAlignment="center" /> <!-- items inside

How to set RecyclerView item max height relative to parent

被刻印的时光 ゝ 提交于 2021-02-10 17:58:46
问题 I've almost got this working by following the suggestions in this question Android percent screen width in RecyclerView item However that sets a height for all views, same height regardless of the content. In my case I just want to limit how tall an item inside the RecyclerView can be related to its height. In my RV I have items that have different heights, with some of those items capable of being even taller than the RV. My goal is to tell that the item can be at max 60% of the RecyclerView

How to set RecyclerView item max height relative to parent

徘徊边缘 提交于 2021-02-10 17:55:41
问题 I've almost got this working by following the suggestions in this question Android percent screen width in RecyclerView item However that sets a height for all views, same height regardless of the content. In my case I just want to limit how tall an item inside the RecyclerView can be related to its height. In my RV I have items that have different heights, with some of those items capable of being even taller than the RV. My goal is to tell that the item can be at max 60% of the RecyclerView

How to set RecyclerView item max height relative to parent

核能气质少年 提交于 2021-02-10 17:54:40
问题 I've almost got this working by following the suggestions in this question Android percent screen width in RecyclerView item However that sets a height for all views, same height regardless of the content. In my case I just want to limit how tall an item inside the RecyclerView can be related to its height. In my RV I have items that have different heights, with some of those items capable of being even taller than the RV. My goal is to tell that the item can be at max 60% of the RecyclerView

Android app keeps going back to main activity UI when I try to display something using an adapter on the current activity

浪子不回头ぞ 提交于 2021-02-10 06:45:55
问题 I am very new to android development and am building an app that can read characteristics from a BLE device. I am able to connect to a device and read its characteristics. However, I have a problem is displaying the characteristics using an adapter. Initially, I tried using the RecycleView adapter but my program kept going back to the main activity as soon as I tried to notify my recycleview adapter and everything left on the Logcat would be this: 2020-11-24 13:35:37.220 12966-12966/? I

Android app keeps going back to main activity UI when I try to display something using an adapter on the current activity

爷,独闯天下 提交于 2021-02-10 06:45:18
问题 I am very new to android development and am building an app that can read characteristics from a BLE device. I am able to connect to a device and read its characteristics. However, I have a problem is displaying the characteristics using an adapter. Initially, I tried using the RecycleView adapter but my program kept going back to the main activity as soon as I tried to notify my recycleview adapter and everything left on the Logcat would be this: 2020-11-24 13:35:37.220 12966-12966/? I