I display my JSON data into a RecyclerView. I have multiple TextView into one item and it works perfectly.
In my data, I need to fetch photos and display them into each item. I have multiple photos for one item. It starts from 6 photos to... many more.
I tried using a RecyclerView inside my first RecyclerView but as you can guess it was a bad idea (bad performance, not the good result expected and so on).
Do you have any other solution or advice that might help, please?
I found a thousand solutions how to display one picture by row but none about multiple pictures into one row.
Create a custom view and add Image views dynamically based on no.of views required.
Use this view in the recycler view adapter itemlayout file.
Related
Basically, I have a bunch of custom TextViews and a set of data. I programatically inflate the textviews and set their texts according to my data. I want to add my views to the right of each other, and when there is no room horizontally, it will add a new row below. However, I am not sure what layout/view to use to achieve my goal.
Example of what I am trying to achieve:
enter image description here
Please Help!
I would use the Flexbox Layout library from Google. It does exactly this for you.
I have say 3 images in a view and want to display a list upon selecting any of the images. Upon selecting an image a list shows up adjacent to the image that was selected. Only one list can show at a time, so if a list is visible next to one image and another image is selected a new list is built next to the selected image and the existing list disappears.
The lists are built using arrays.
Should I use listview or listactivity. Or might there be a better approach to doing this.
Thanks,
you can use Recyclerview List for your mentioned problem
The easiest way, according to me, is to make the layout as you want with the images and with listviews and put initially visibility gone on the lists. When a image is clicked make that list visible (setVisibility(View.VISIBLE)) and the other ones gone (setVisibility(View.GONE)).
This is the most straightforward solution.
I'm using Retrofit2 to handle http comunication with backend. In response I'm getting data that i wish add to number of views specified in JSON file (size of array).
I want to create views like this but not the same. Basically picture and some text
I don't know what type of layout i should use. Grid, Relative, Linear, List? I also want to scroll this views.
You should maybe use recyclerview with cardview items.
You can set a scroll listener to the recyclerview , to define when you want to upload some new data .
I have came across these type of questions a lot, But none of the answers solved my problem.
I am developing a mobile shopping application model. I have a custom ListView with an ImageView, and EditText(quantity), 2 Buttons for increasing and decreasing the quantity, 3 TextViews one for item Name and other two for prices and I am dynamically loading a number of Buttons for NetWeights based on the requirement through Java code and I am implementing it using CustomAdapter(Class) extending BaseAdapter and getView().
Problem 1:
When I use the condition if(convertView==null), setTag(holder) and getTag(), the dynamically loaded Buttons are getting duplicated and gets doubled in number.
Problem 2:
While scrolling the custom ListView I am loosing my data on 2 of the TextViews while the other TextView(name) is fine because in that TextView I don't Change data on runtime. On the other two TextViews(prices) I change the data on runtime using ButtonClicks(increase and decrease) where at that time when I scroll the two TextViews, it looses its content. Actually I had this same problem with the EditText(displaying quantity), I solved it using the TextWatcher by getting the value and passing it in an array and again setting it. I used the same technique (i.e) the TextWatcher for the TextViews But that did'nt Help. I also tried removing the TextWatcher and setting the text with the array and adding TextWatcher. Still I am loosing my content in those TextViews
Any Suggestions??????
Problem 1:
While using ViewHolder (setTag(), getTag()) we will be reusing the views.
For example: Let's say we have 10 listview items and the screen can display 3 items at a time. Lets say we add 2 buttons to list item 1. First time when we load the listview we will see two buttons. Lets say now we scroll down and come back to the list item 1 again, as we are reusing the views, we already have 2 buttons and if we have the code to add buttons using getTag() then 2 more buttons will be added. I think this may be causing the issue of button duplication. To add little more information, list item 1, list item 4, list item 7 and list item 10 will all use same view, as our screen in this example can display just 3 items.
Problem 2:
One idea is to store all these text values in the arrayList.
For example, lets assume we have one textView inside each list item that can be incremented/ decremented. Set textWatcher on this textView and whenever text changes add it to the arrrayList using 'position' as the index. Inside getView method when you do getTag() try to set the textView using previously stored text (that was stored inside the arrayList)if exists.
I'm trying to design a page for my app that will be a list of places. I need each list entry to have a picture, text below, short description, and some other info, address
The list view fragment examples that I've seen simply have one or two lines which won't really do what I need it to... where do go from here? I'm not sure what to search for, nothing useful has come up so far..
You are going to need to make a custom ArrayAdapter.
Check out some of these examples:
Android Custom Listview with Image and Text using ArrayAdapter
Android Custom ListView with Images and Text – Example
Customizing Android ListView Items with Custom ArrayAdapter