android-adapter

ListView (Adapter) item visibility listener

余生长醉 提交于 2019-12-10 13:53:26
问题 Is it possible to have a visibility listener on each listview's item? Like: on user sees the item, do something. On item is hidden, do something else. I want to check when a item "enters" or "exits" the scroll so as to update a second list. Additionaly my ListView might expand like: adapter.addAll( (Collection<? extends DBObject>) events); adapter.notifyDataSetChanged(); I think a way might be to use a global listener to check the items but I am afraid it will get messed up if I add more

Change listview adapter to recycler view adapter

╄→尐↘猪︶ㄣ 提交于 2019-12-10 12:35:27
问题 When I load images from SD card to ListView, it starts lagging. I can not scroll smoothly. So, I decided to use recycler view and maybe Picasso. The only problem I am facing is that, ListView adapter is not working with RecyclerView. How can I rewrite the following code/adapter to work with RecyclerView? All the best and Happy New Year! public class Saveditems extends BaseActivity { ArrayList<String> f = new ArrayList<>();// list of file paths File[] listFile; @Override public void onCreate

Custom adapter for FirebaseAdapter to a HorizontalScrollView or Carousel

百般思念 提交于 2019-12-10 12:34:38
问题 I have a simple RecyclerView where I show all the products from firebase but now I'd like to show them on a Carousel like this Library, the thing is that I have all on my ChooseProduct.java class and I'd like to create a custom Adapter to put the products as a Carousel . First I get the products as follows : FirebaseRecyclerOptions< CardPOJO > options = new FirebaseRecyclerOptions.Builder< CardPOJO >() .setQuery(products_ref, CardPOJO.class) .build(); And I store it on options , so then I

Listview not getting populated, getView() isn't getting called

萝らか妹 提交于 2019-12-10 12:31:04
问题 I'm having a few problems getting my listview to show up in a simple application i'm writing. For some reason the getView() method of my adapter class isn't getting called. However, when when getCount() is called in my adapter class it isn't returning 0 but is in fact returning the proper value. I'm really confused as to why this isn't working. Here is my Activity: import android.app.Activity; import android.os.Bundle; import android.widget.ListView; public class CardListActivity extends

RecyclerView Adapter Lint Error do not treat position as fixed

拥有回忆 提交于 2019-12-10 11:51:27
问题 I have surf this type of error but I didn't get what can I do in my case. I am getting following lint error. Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later. RecyclerView will not call onBindViewHolder again when the position of the item changes in the data set unless the item itself is invalidated or the new position cannot be determined. For this reason, you should only use the position parameter while acquiring the related data

Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object ref [duplicate]

与世无争的帅哥 提交于 2019-12-10 11:09:20
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 years ago . I'm trying to display data in a listView. I have the current code attempting to take an array that is passed in from the myDatabase class, and then display this within my listView. However I got an error : "Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference". My code is working in main

Custom android adapter with generic class

帅比萌擦擦* 提交于 2019-12-10 11:07:27
问题 I'm trying to create a generic adapter in Android, so i can not write it over and over. The thing is,it's working, but it's not recycling very well, it displays what i want but when i scroll, it's not in the same order. public class CustomListViewAdapter<T> extends BaseAdapter { private List<T> objects; private LayoutInflater inflater; private int resources; private AdapterCommand<T> listener; private ViewHolder h; public CustomListViewAdapter(Context context, List<T> objects, int resources,

ListView Adapter with multiple Item layouts

落爺英雄遲暮 提交于 2019-12-10 10:58:41
问题 I'm looking at adding a listview to my Android application with a thumbnail image. The thumbnail on the left and text on the right. Is there any way of populating the list view with seperate xml files, for example, could I have separate xmls for Austria, UK, USA etc and add them to the listview? The reason I ask is, I plan to reuse the individual countries multiple times, as in, shown in an A to Z but then again by Continent etc. If this is possible, could I get an example of how this is done

Android : RecyclerView row Visibility not working properly

笑着哭i 提交于 2019-12-10 10:12:21
问题 I am developing an android app (Android Studio). I want to implement Visibility GONE/VISIBLE in every row. In the image there are three recyclerView rows, I want to do the following things : There are two part in every row Heading & Details . When This Activity open all the rows details should hide. When I click on particular row , details of the row should appear by Visibility VISIBLE. When i again click on row details should disappear by Visibility GONE. Problem is : If i clicked on first

Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference [duplicate]

こ雲淡風輕ζ 提交于 2019-12-10 09:58:18
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 2 years ago . So I have Android app with Tabs and RecyclerView . When I run my app, it crashes. logcat: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at java.io.StringReader.<init>(StringReader.java:47) at android.text.HtmlToSpannedConverter.convert(Html.java:442) at android.text.Html.fromHtml(Html.java