I am creating a costum ListView
In this ListView I have the a list.xml with an item which has an image and three text fields.
Now to my problem :P
How can I add this custom ListView ITEM to my ListView (after a Button from another activity is clicked) and save it somewhere like in SQL...
Don't use ListView. Use RecyclerView instead.
https://developer.android.com/training/material/lists-cards.html#RecyclerView
You need to create adapter where you point proper XML file for an item
1. First, create a custom layout XML for your list row item(Image and 3 TextViews).
2. Create a custom adapter class to populate your ArrayList<OBJECT> on custom list row XML.
Here are some good tutorials:
Android Custom ListView with Image and Text
Android Custom ListView with Image and Text using Volley
Android Working with Recycler View
FYI, You can use RecyclerView instead of ListView. Android RecyclerView is more advanced version of ListView with improved performance and other benefits.
Hope this will help~
Related
Is it possible to have some listview rows have a checkbox, or a switch and others to nothing just a title and remain clickable.
I am trying to a do a listview that has a few different settings.
First - Checkbox
second - Switch
Third - Just list.
I know I could do them as separate buttons I would like to have them filled from the same array if possible?
YES Definately Its possible...
1. Create a custom layout for ListView or RecyclerView row item with CheckBox, Switch, TextView or other views as per your requirement.
2. Create a custom adapter extending from ArrayAdapter, BaseAdapter or RecyclerView.Adapter to populate list data to your custom layout.
3. In getView() or onBindViewHolder() method, set data to your views and add required OnClick or OnCheckedChange listener to your Views.
Here are some tutorial link:
Android Custom ListView with CheckBox
Android RecyclerView with CheckBox
ListView with CheckBox using custom Adapter class
Android ListView with Checkboxes
Android Custom ListView with Image and Text
Hope this will help~
I want to create item adapter with a mosaic view include multiple images.
I found some libs: AndroidMosaicLayout,
QuiltViewLibrary.
But these show on the main view. In my case, I want to show images on the item adapter recyclerview.
It's same the row on facebook row new feed.
Any help, thanks.
You cam do it using the library AndroidMosaicLayout. In the layout used for the adapter of the RecyclerView just add the view of AndroidMosiacLayout and inside the recyclerview adapter, just inflate the layout resources and access the AndroidMosiacLayout normally by assigning the required layout pattern and data. At the end the AndroidMosiacLayout it is just a NestedScrollView, so you can use it the same way you use any other view or view group.
I have a ImageView with a TextView and Button. I have it currently in a custom list view, but I noticed now that I don't need to show more as one element (object). So I actually don't need a Listview to show the row (list entry). How can I show the list entry without a Listview?
You can put the elements of your custom listview item into a Layout, e.g. LinearLayout and simply add it to your activity's layout where you needed it.
You can set an OnClickListener for that layout, so user can click the whole thing.
I think you should use ListActivity. Then you can set up empty view for list. Here some tutorial: ListActivity and ListView Tips.
Also you can implement that logic with Recycler view by yourself or use library.
Here is solution from stackoverflow
I am working Android application, Using ListActivity to create ListView then i tried to add ToggleButton inside the ListItems, but i didn't know that, please help me
Thanks in Advance
Here are the steps by which you can create Custom ListView:
Create row layout for your listview item which you want for ListView
create custom adapter by creating a separate class, and extend BaseAdapter
Override getView() method, inflate the above item row layout and display the data
For more info: android custom listview And if you want to learn about: AdapterViews and Adapters
I am trying to have a layout with 6 TextViews and a Custom List.
TextView number 3,4,5 have images next to them,followed by the Custom List.
The custom list is done , but I am not sure how I can get the upper part ( TextView controls and images ) and the custom list in one layout.
For other custom lists I have always extended from ListActivity and set the list adapter in the same class as it is the only control on the screen.
In this case the class extends from Activity,how can I set the list adapter in the Activity class ?
Any pointer's to achieve this layout and which layout will be the optimal choice(Linear,Relative..) ?
Thanks,
Salil.
I found the answer to my problem.
Add a listview to the layout xml
Get the listview object using findViewById
User etAdapter to set the custom list adapter
Now I can use the custom list along with other controls in the same Activity.
Thanks,
Salil.