List View App Android Studio Tutorial Using Custom Adapter

List View App Android Studio Tutorial Using Custom Adapter

Code With Cal

4 года назад

11,216 Просмотров

In this tutorial we build a simple List View app in Android Studio using Java.

I will demonstrate how to build a list view using a custom adapter. Our adapter class is going extend ArrayAdapter.

We will also implement an on click listener for our list view. So that when you tap on any given row in our list we will taken to a detail activity. To achieve this we will pass our selected item to our detail activity via an intent using put extra.

Our List View will use a custom class of Shape for this example to populate each row. The principles applied here could be used for any custom class that you would like to create a list view for.

Shape List Images:
https://drive.google.com/drive/folders/17ukEYp8fFRCNYmr-zr9LST7_cCTBG0Id?usp=sharing

Tutorial 1 (This video) - How to build a List View
Source Code: https://github.com/codeWithCal/Shapelist
Link: https://youtu.be/6qYNxtG0LNE

Tutorial 2 - Search and Filter List View:
Source Code: https://github.com/codeWithCal/Shapelist/tree/shapelistWithSearch
Link: https://youtu.be/M73Vec1oieM

Tutorial 3 - ListView with search, filter, sort & toolbar:
Link: https://youtu.be/uvbibj7w2KE

Tutorial 4 - ListView Multi-select filters:
Link: https://youtu.be/liGwWbR-2D8

⏱️TIMESTAMPS
00:00 - Intro
00:25 - Set up
01:20 - Shape Class
02:19 - Layouts
03:59 - Adapter
07:29 - List Activity
10:52 - On Click Listener
13:19 - Detail Activity
15:43 - Testing

#ListView #AndroidStudio #AppDevelopment #CustomAdapter

Тэги:

#Android #Android_Studio #andriod #java #tutorial #listview #list #view #simple #how_to #programming #coding #code #android_studio #list_view #android_programming #android_app #Australia #on_click_listener #2020 #item #click #cell #adapter #activity #on_click #listener #instance #custom #beginner #example #friendly #learn #app #android #studio #row #tableview #how #to #layout #detail #shapelist #intent #on #listen #putextra #put #extra #table #shape #tute #demonstrate #basic #rows #pass #detailActivity #detailview #array #arrayadapter
Ссылки и html тэги не поддерживаются


Комментарии:

Pamela Pugh
Pamela Pugh - 13.08.2023 19:55

@CodeWithCal Great tutorial! My listview loads up perfectly but the onclick is not working when I select an item from the list, instead, the program crashes. I've looked at the other .java files and I can't find any issues. Would you mind taking a look at my code?

Ответить
john lloyd escaño
john lloyd escaño - 04.06.2023 14:34

i have a problem. when i click view it show "building name" and no image. please help me

Ответить
Thang Lemon
Thang Lemon - 01.10.2022 13:25

Thank you so much, I really really appreciate that, keep up the good work bro :)

Ответить
StepBros Live
StepBros Live - 11.07.2022 05:54

Great tutorial, it really helped. Every thing loads fine the first time the activity is ran, however if I go to another activity then return the list is doubled. How can I save the progress on a page so it is the same each time I load it?

Ответить
Kirazami
Kirazami - 17.05.2022 23:04

Hi Cal, do you happen to know why my listview is duplicating cells ? thanks a lot

Ответить
Viniz Medrano
Viniz Medrano - 23.04.2022 02:24

thanks man, you helped me a lot in college with this video.

Ответить
Asma
Asma - 15.08.2021 18:15

Hi cal ..
I try to write your code but i need your help to resolve my problem please am student and i really really need your help

Ответить
M-J -Y
M-J -Y - 04.07.2021 14:11

Could you do a video where you show how to add and delete things from the list as well?

Ответить
Kevin
Kevin - 24.06.2021 09:13

put your paypal account so I can give you some money if I get the job. thanks for everything, learned a lot, coming from java and definitely android is a lot more abstract than normal java, I will take some time to get use to the built in classes that android studio has.

Ответить
India.loves.you.BJP.2024🇮🇳
India.loves.you.BJP.2024🇮🇳 - 22.05.2021 09:29

Sir thank you soo much sir! great work! i will share it with all my friends!

Ответить
Ciel e Kaah
Ciel e Kaah - 09.05.2021 23:04

How do I create an action to open a new activity when I click on an item in the list?

Ответить
Khaled NoorElDeen
Khaled NoorElDeen - 18.01.2021 11:51

Thanks a million Cal for the outstanding tutorial. Works like a charm!!

I just have one question, when scroll down the listview and click on any item (item number 30 for example) , it goes to its detailed activity perfectly. But when i get back to the listview again, the list starts all over from the beginning (from item number 1), not from the item which I clicked. Is there a way to do that? That would be really appreciated.

Ответить
Your FingerOnScreen
Your FingerOnScreen - 27.11.2020 17:12

Your tutorials are great, a sunshine ray of java through all that Kotlin stuff on all the Internet. At universities in general, they require java a lot. All I know I learned from your channel, thanks!

Ответить
Rizky Mahendra
Rizky Mahendra - 23.11.2020 07:05

Somehow i found your channel, useful tutorial for me, i wish you have better future on your channel. Thanks for the tutorial!

Ответить
ultimat papayou
ultimat papayou - 06.10.2020 18:46

Bonjour, je sais pas si vous allez pouvoir me donner l'info. J'ai créé une liste view et je croyais pouvoir attacher une autre liste wiew mais je n'y arrive pas. Mon projet et de présenter des articles de péche et pour cela j'ai besoin de créer des catégories exemples A1) matériels de pêche et B1) matériels vêtements de pêche sous catégories Aa1 accessoires de pêche les bouchons Ab1 les apats Ac1 les Cannes à pêche.... et une dernière sous catégorie Aaa1 les bouchon bois Aaa2 les bouchons pvc Aaa3 les bouchons..... Et après la fiche de l'article. Comment procéder. J'ai cherché et rien trouvé si vous pouviez m'orienter ou me donner une source ou autre je suis preneur. Merci beaucoup par avance.

Ответить
Vlad Stici
Vlad Stici - 17.08.2020 10:44

Thanks

Ответить
Saleh Hussain
Saleh Hussain - 17.08.2020 06:02

I'm just wondering how are you able to write in this small-sized text??
Seriously regardless of the viewers!

Ответить