Android Beginner Tutorial #8 - Custom ListView Adapter For Displaying Multiple Columns

  Рет қаралды 222,690

CodingWithMitch

CodingWithMitch

7 жыл бұрын

Android Beginner Tutorial #8 - Custom ListView Adapter For Displaying Multiple Columns
By the end of this video you will know how to:
1) Display multiple columns in your ListView
2) Build a ListAdapter class to display custom ListViews
3) Build custom layouts for your ListView items
➤Source Code:
↻ github.com/mitchtabian/ListViews
➤My Keyboard:
↻ goo.gl/1RUqgb
➤My Microphone:
↻ goo.gl/mPh3dk
➤Check out our website:
↻ www.CodingWithMitch.com

Пікірлер: 166
@Atoa6CrewProd
@Atoa6CrewProd 6 жыл бұрын
You really helped me man I've been looking for a solution like yours for weeks ! Thank you
@OomptzMusic
@OomptzMusic 5 жыл бұрын
This is the tutorial I have been looking for!! Thank you!
@aniket617
@aniket617 5 жыл бұрын
Thanks a lot, Mitch. Your videos are a very useful source to learn from
@samueltremblay4181
@samueltremblay4181 3 жыл бұрын
Thank you so much ! This video is so great and exactly what I needed. Everything was so clear and the explanations were great !
@amjad-se
@amjad-se 5 жыл бұрын
Clear and straightforward. Thanks
@MohammadOla
@MohammadOla 4 жыл бұрын
If I didn't learn anything except "Alt+Insert" shortcut, that would be enough. It is very very helpful shortcut. Great video also, so thank you.
@prasadmadushan
@prasadmadushan 5 жыл бұрын
very informative, within few minutes you gave us more ,thanks for that
@relaxingcat4159
@relaxingcat4159 7 жыл бұрын
Your videos are very helpful, thanks dude :)
@noobandnerd6543
@noobandnerd6543 2 жыл бұрын
Auch wenn diese Videos schon älter sind, vielen dank dafür. Das hat mir gerade sehr geholfen.
@errolniel3410
@errolniel3410 5 жыл бұрын
Mitch, great video. Can you explain how to create that custom listview to display data from SQLite database that is also numbered?
@rgubri3711
@rgubri3711 3 жыл бұрын
Thanks a lot for the nice tutorial and sharing it over github. you saved my time.
@HonoredPotential
@HonoredPotential 6 жыл бұрын
Thanks man, very useful.
@daniellagofman8407
@daniellagofman8407 3 жыл бұрын
So helpful, thank you!
@Vlad-xh9sy
@Vlad-xh9sy 6 жыл бұрын
Thanks really helpful!!!
@allenrowland3132
@allenrowland3132 7 жыл бұрын
This is a very helpful video to learn from t thanks.
@yektacirpan6126
@yektacirpan6126 7 жыл бұрын
Super, merci !
@MiguelLopez-zg7qe
@MiguelLopez-zg7qe 7 жыл бұрын
Thanks. Very helpful!!
@sharathbabuvanam8851
@sharathbabuvanam8851 6 жыл бұрын
Miguel Lopez
@vahidhoseini1723
@vahidhoseini1723 3 жыл бұрын
great, good job mitch.
@lucasalvesdossantos3993
@lucasalvesdossantos3993 2 жыл бұрын
Thank you for the video!
@EXASHES
@EXASHES 4 жыл бұрын
Thanks for the help! :)
@Davsan1
@Davsan1 5 жыл бұрын
You never used the "person" variable you created in the end
@simonpetera2486
@simonpetera2486 7 жыл бұрын
Awesome!!! Thank you a lot!!! :) :) :)
@ZakariaF
@ZakariaF 4 жыл бұрын
Thank you so much , my teacher's code didn't work but yours did !
@JesusChristIsLord__
@JesusChristIsLord__ 5 жыл бұрын
Thank you so much for your help!! Just want to add this... in the getView() method, you could have used: Person person = getItem(); and then do: tvName.setText(person.getName()); ... etc.
@yesitshassan
@yesitshassan 4 жыл бұрын
getItem(position)*
@subbamaggus1
@subbamaggus1 4 жыл бұрын
hey, i know its not the newest video anymore. BUUUT: i spent like the complete last weekend trying to understand the generated examples by android studio... no success. with yours, it took me an hour to have my first custom listview up and running. thank you sooo much!
@joelvarghese3370
@joelvarghese3370 4 жыл бұрын
Why did I learn about this channel so late!?!?!?! This was an awesome tutorial. YOu just earnes yourself a subscriber @CodingWithMitch
@codingwithmitch
@codingwithmitch 4 жыл бұрын
KZfaq doesn't like me because I made fun of flutter babies
@badal8435
@badal8435 3 жыл бұрын
This is very easily explained great sir , from india:-)
@benjaminlee8290
@benjaminlee8290 3 жыл бұрын
Thank you very much!
@brukselkowyben7628
@brukselkowyben7628 4 жыл бұрын
Great Tutorial, it helped me in creation football highlights app :D
@j.clinton3324
@j.clinton3324 7 жыл бұрын
Awesome, now I can get my database values in a list with the corresponding columns. Thanks
@rogarmu888
@rogarmu888 7 жыл бұрын
J. Clinton srry, how r u passing the whole column to the list?
@j.clinton3324
@j.clinton3324 7 жыл бұрын
I made a Cursor in which I stored all of my table's data. Then instead of creating a new object("value1", "value 2", "value 3") I created a new object(res.getString(1), res.getString(2), res.getString(3)) and of course stored it in a variable, so Object var = new object(see above). Then Array.add(var) and put both in a while moveToNext loop
@rogarmu888
@rogarmu888 7 жыл бұрын
J. Clinton thx for fast aswering, I will try it!
@j.clinton3324
@j.clinton3324 7 жыл бұрын
No problem, good luck
@user-xb7mf7qy6v
@user-xb7mf7qy6v 4 жыл бұрын
Best tutorials, thank you so much
@Go-ik5nk
@Go-ik5nk 4 жыл бұрын
Здраствуйте, у меня возникла проблема с использованием getName(), getBirthay()... в классе PersonListAdapter. Они просто напросто горят красным
@lukes459
@lukes459 6 жыл бұрын
Thanks for the help bro
@thekilleronden
@thekilleronden 4 жыл бұрын
Thanks! :D
@MrRynRules
@MrRynRules 4 жыл бұрын
Thank you!
@thelegendofpit
@thelegendofpit 5 жыл бұрын
What a great video
@pikachubolt2001
@pikachubolt2001 4 жыл бұрын
Hello I am getting an java null pointer exception and logcat says its from layoutinflater line of code i followed everything in the video and the only problem is the layoutinflater returning a null value please help, ill just use the built in lists for now ty
@Manikandan-nn2bw
@Manikandan-nn2bw 2 жыл бұрын
@2:12 I think the explanation regarding 'weightSum' and 'layout_weight' is incorrect. I think, layout weight of 66.6 will indeed occupy 2/3 of parent layout width. But for it to work right, we need to set layout_width="0dp" to horizontal linear layout and layout_height="0dp" in vertical linear layout. Kindly correct me if I got it wrong.
@yulianore
@yulianore 3 жыл бұрын
thank you very much bro
@serafinkozinski695
@serafinkozinski695 5 жыл бұрын
It is very helpful to create custom listview
@vicentselfa
@vicentselfa 4 жыл бұрын
Easy, clear and perfect for me. Thanks!
@davidedipierro8717
@davidedipierro8717 3 жыл бұрын
Great job bro!!
@davidedipierro8717
@davidedipierro8717 3 жыл бұрын
Te lo sei meritato il like frà
@vigneshkumar6396
@vigneshkumar6396 3 жыл бұрын
Thq sir now I am understand
@waleedware7779
@waleedware7779 7 жыл бұрын
Great tutorial, any chance you can make a tutorial on how to load multiple deferent row in a single list view depending on an a condition in the array. for example an array of cars with deferent row style depending on car maker.
@chitrajoseph4239
@chitrajoseph4239 5 жыл бұрын
Thank you
@captainmus1292
@captainmus1292 7 жыл бұрын
Thank you this is very helpfull..but I had an issue that is my view shows false no matter what value I set on the text xml
@ayalsh1398
@ayalsh1398 2 жыл бұрын
It worked and now I love you ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
@sutharshanratneswaran4497
@sutharshanratneswaran4497 5 жыл бұрын
Thanks for your Video. It very helps to understand listView. Can you upload a video "listview with alphabetical side index"?
@camstephens5534
@camstephens5534 7 жыл бұрын
What would be a good approach for changing the Data to take in User Input? BTW Awesome Video!!!
@SwadhyayGroup
@SwadhyayGroup 6 жыл бұрын
can you tell how i can display data that is stored in firebase using custom adapter in list view Please tell me
@-sodaem1134
@-sodaem1134 5 жыл бұрын
hello How can I create 2 listview in app , when i click on item in first listview open to me a second listview ? Please reply to me because I stopped because of this problem .
@HH_Linkmusic
@HH_Linkmusic 4 жыл бұрын
Are there special reason you used layout_width="match_parent" and weight, instead of using layout_width="0dp" and proper weight(ex 1:2 )to TextView and LinearLayout ?
@_Master_P
@_Master_P 5 жыл бұрын
my position in the getView doesn't update so i get the same data, do you know why?
@weinchia8836
@weinchia8836 7 жыл бұрын
can i know how to remove an item from the listview with setonclicklistener using this code?
@izioakerman9754
@izioakerman9754 3 жыл бұрын
Thanks for your tutorial. I am trying for a few days without success using your example to implement the search view and nothing appears. May you help me? Thanks in advance.
@chadisfeir3809
@chadisfeir3809 6 жыл бұрын
Hello thank you for your video! can tell us how to implement onitemclicklistener ?
@introvertsdiary
@introvertsdiary 3 жыл бұрын
So you have any tutorial on how to add data by typing it in edittext then put it on the list.. I dont want to hard code the list items
@ravinder.singh.
@ravinder.singh. 6 жыл бұрын
Hey man, video was superb but i am looking for fetching data from the sqlite db and display the data on to the list.
@mreffect_dev
@mreffect_dev 2 жыл бұрын
Спасибо
@pigasaur2781
@pigasaur2781 5 жыл бұрын
Hi how come this doesnt work with the search filter that you have in your previous video??
@slaviboy
@slaviboy 5 жыл бұрын
Bro use for-loop to generate Person() objects with random value, and add them to the list.
@JZainbear
@JZainbear 5 жыл бұрын
Where is the person object in the getview method being used? My code says the variable is never used.
@lapnghiepshopee
@lapnghiepshopee 6 жыл бұрын
what tool do you use design??
@brucewayne3518
@brucewayne3518 5 жыл бұрын
once the multiple values are added in the single item of list view how to retrieve those values from each item
@zahidhussain3453
@zahidhussain3453 7 жыл бұрын
i don't understand where are you calling the getview method to set the info on the listview
@zonico5826
@zonico5826 7 жыл бұрын
I think the adapter itaelf deals implicitly with this method
@aishwaryakulkarni9452
@aishwaryakulkarni9452 7 жыл бұрын
Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed with multiple errors, see logs I am getting this error...I tried to add activity in manifest for other java classes but it is showing error can you please suggest me a solution for this?
@ryowijaya4676
@ryowijaya4676 6 жыл бұрын
What if I just wanted a normal simple listview with just one sub-item?
@yvindlyse8623
@yvindlyse8623 5 жыл бұрын
The tutorial was made with Android Studio 2.2.3, while I tried using version 3.3.2 and got some errors: The getName(), getBirthday() and getSex() methods won't resolve. Should this code even work in the newer AS versions?
@HH_Linkmusic
@HH_Linkmusic 4 жыл бұрын
hi I use AS 3.5, no this kind of problems.
@Go-ik5nk
@Go-ik5nk 4 жыл бұрын
I have such problem. Have you solved it?
@SzubiX
@SzubiX 6 жыл бұрын
+Mitch Tabian I got the question. I want to improve my ListView from your tutorial "Save data into SQLite database [Beginner Android Studio Example]" I want to have custom ListView here but when i try to merge code from here with Sqlite coding style i have an error with Error:(59, 82) error: incompatible types: ArrayList cannot be converted to ArrayList. Can u help me ? It would be great! Thanks and greetings from Poland!
@SzubiX
@SzubiX 6 жыл бұрын
I watched your Video called Adding multiple columns to your ListView (part 2/3) and resolved problem by myself! Still a lot work but small step completed! THANKS!
@SzubiX
@SzubiX 6 жыл бұрын
Mitch Tabian got another question. I have the project with basketball statistic, and i want to connect my teams database For every team i want to create another database with players. Can i find this on your courses?
@SzubiX
@SzubiX 6 жыл бұрын
SQLlite doesn't handle this type of project? Why ?
@SzubiX
@SzubiX 6 жыл бұрын
I did the team data base of teams but yeah got the problem with connect this with players database. Finally i change the idea of the project with firebase help. I watched few yt videos about firebase and i think i can handle this. Also thanks for giving me your firebase courses , hope it will help me. U re great guy! And half polish also ;)
@joannakim8118
@joannakim8118 6 жыл бұрын
why did you create linearlayout inside linearlayout?
@Slacker28
@Slacker28 5 жыл бұрын
It says I need the Gradle view system?
@castro6612
@castro6612 5 жыл бұрын
what is the use of android:layout_belows=" "?
@meetpatel-xn7uo
@meetpatel-xn7uo 6 жыл бұрын
How can I delete items from a ListView with this customAdapter?
@atinpal8660
@atinpal8660 5 жыл бұрын
what if i want to populate this with sqlite database?
@talibdaryabi9434
@talibdaryabi9434 5 жыл бұрын
why u created the person object inside the getView() method? what's the use of it? BTW ur tutorial helps us a lot we appreciate your efforts.!
@toddprickett6376
@toddprickett6376 Жыл бұрын
I came to the comments to ask the same question. I don't see any purpose for creating the Person object as it never seems to be used anywhere.
@kazz94
@kazz94 5 жыл бұрын
what does the "m" stand for in "mContext"?
@rialseebran2072
@rialseebran2072 4 жыл бұрын
it's just a coding technique so that you know it's a user created variable
@goat813
@goat813 3 жыл бұрын
When you created the String name = getItem(position).getName(); Where did you get the getName() from ?
@user-cl5wn9fz7f
@user-cl5wn9fz7f 3 жыл бұрын
Why don't you use jetpack compose
@fernandoluis53
@fernandoluis53 4 жыл бұрын
I can't add more than two views for my view cell. Any tips?
@mini.aakash
@mini.aakash 2 жыл бұрын
Did actually everything same but my app crashed even before opening, what to do? OR what can be the possible error Ps: - I have checked all the code again and again
@tamirmoav3774
@tamirmoav3774 2 жыл бұрын
what is getItem in line38? where is it defined?
@lyusientsvetkov6816
@lyusientsvetkov6816 4 жыл бұрын
I'm wondering how can I set OnItemClickListener to get the name of my item using the it position and setting a text unto a textview. Could you help me on that? my_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView View view, int position, long l) { // The problems is here I stuck at getting just the name but not the entire row. if (position==0) { my_textview.setText(THE CLICKED ITEM NAME); } });
@bobstone9660
@bobstone9660 7 жыл бұрын
how did you use person class in mainactivity class without extending person class?? Cannot resolve symbol ''person' showing
@bobstone9660
@bobstone9660 7 жыл бұрын
No, i created ''person' instead of 'Person' and i called it with caps 'P' in main activity...silly mistake.Thanks for your reply.
@simonbaker9909
@simonbaker9909 4 жыл бұрын
I don't understand your "weightSum" and "layout_weight" strange reversal where the larger layout_weight ends up smaller. I think it has something to do with setting the children "layout_width" to "match_parent" instead of "0dp". If you change the "layout_width" of the child views to "0dp", then you don't get the strange reverse arithmetic and the weights work as expected.
@James-cq9dp
@James-cq9dp 5 жыл бұрын
why are you creating a person object in getView if its not being used?
@Nicodork84
@Nicodork84 5 жыл бұрын
It's says that the apllication keeps stopping!
@MrRynRules
@MrRynRules 4 жыл бұрын
When i had that issue, i realized i was declaring some of the member fields in the wrong section of the code.
@jamaicandjnado
@jamaicandjnado 6 жыл бұрын
I was trying to follow using Kotlin, everything was fine up until this tutorial. I am so lost.
@davidgraves1876
@davidgraves1876 7 жыл бұрын
Dont know what the issue is. But whenever I run it on my Emulator once it tries to run it crashes and says "ListAdapter has stopped." Have you seen this before?
@jainamshah1474
@jainamshah1474 5 жыл бұрын
same problem bro got any solution ??
@imanakbar2071
@imanakbar2071 6 жыл бұрын
thank you :-D i like this.. may you create tutorial like this with sqlite ? :-D
@thoriqanwar5882
@thoriqanwar5882 6 жыл бұрын
Iam having problem in the MainActivity when PersonListAdapter created, the "new PersonListAdapter(this, R.layout.layouts, peopleList);" goes error. please help me
@ricardojesus9313
@ricardojesus9313 6 жыл бұрын
Did you ever solve this? I'm having an issue too
@thoriqanwar5882
@thoriqanwar5882 6 жыл бұрын
@@ricardojesus9313 Yeah, i did but what problem do you have?
@fatihmehmetyuksel9798
@fatihmehmetyuksel9798 5 жыл бұрын
I have the same problem and it says you can't use "this" part.
@Xeno88
@Xeno88 4 жыл бұрын
can you make a video of editing those list view?
@mumujibirb
@mumujibirb 2 жыл бұрын
I can't make the adapter_view_layout, it just thinks it's a new activity.
@TheAsh69
@TheAsh69 6 жыл бұрын
it would have better if had fetch data from sqlite, or can U help me in this matter ?? plz
@codingwithmitch
@codingwithmitch 6 жыл бұрын
I have a course on that: codingwithmitch.com/courses/android-sqlite-for-beginners/
@TheAsh69
@TheAsh69 6 жыл бұрын
CodingWithMitch do I need buy or subscribe or pay to watch tutorial ??
@codingwithmitch
@codingwithmitch 6 жыл бұрын
Ash Ali that course yes, that one isn't free
@yuvrajsinghyadav1608
@yuvrajsinghyadav1608 Жыл бұрын
why you are using personListAdapter insted of arrrayadapter ??
@XAANAX
@XAANAX 5 жыл бұрын
genius
@roelvisser1866
@roelvisser1866 5 жыл бұрын
got stuck badly on this lesson and need it for the next ones to complete, this error code is driving me nuts! error: no suitable method found for getItem(no arguments) method Adapter.getItem(int) is not applicable (actual and formal argument lists differ in length) method ArrayAdapter.getItem(int) is not applicable (actual and formal argument lists differ in length) cant find a solution anyware.. somebody has a suggestion ? thx
@codingwithmitch
@codingwithmitch 5 жыл бұрын
You should use a recyclerview anyway. Watch my recyclerview video. They are superior to Listviews
@roelvisser1866
@roelvisser1866 5 жыл бұрын
thx for your answer, i am looking at your recyclerview video right now. Gonna try it for sure. However still couldn't find a solution on internet for the error code i am geting in the listview adapter. The problem is in this segment : String name = getItem().getName(); String birthday = getItem().getBirthday(); String sex = getItem().getSex(); any tips how to solve this brainbreaker (at least for me haha) @@codingwithmitch
@flyingpingo1799
@flyingpingo1799 4 жыл бұрын
Hoping there is anyone still active here: Does anyone know, whether it's possible to apply an onclicklistener to the created textviews in the listview?
@VectorNodes
@VectorNodes 4 жыл бұрын
Absolutely, though if you're using them to pass unique IDs through intents for loading videos or profiles etc, or downloading stuff from a server you'll want to cache them before you open the new intent or you'll wind up with weird behavior like crossed names/images, excessive server traffic, or worse. I would also suggest caution when generating certain elements programmatically in the case you need view IDs. If you do that you'll need to keep IDs in an XML resource file and will crash the moment you load an element out of the range of your XML file. Here's an example: @Override public View getView(int position, @Nullable View view, @NonNull ViewGroup parent) { String name = getItem(position).getName(); String id = getItem(position).getId(); LayoutInflater inflater = LayoutInflater.from(context); view = inflater.inflate(currentItem, parent, false); TextView nameTV = view.findViewById(R.id.bluetooth_item_name_TV); TextView idTV = view.findViewById(R.id.bluetooth_item_id_TV); nameTV.setText(name); idTV.setText(id); idTV.setOnClickListener(v -> { Toast.makeText(context, "Item number " + id + " clicked!", Toast.LENGTH_SHORT).show(); }); return view; }
@sixaj
@sixaj 3 жыл бұрын
my getview method is not getting called... :(
@nickbrady1206
@nickbrady1206 7 жыл бұрын
For your layout_weight, if you change to ** layout_width="0dp" ** then it will work more intuitively: layout_weight="66.6" will give you 2/3 of the horizontal space. The problem is that when you have layout_width="match_parent" and layout_weight="66.6" you have two specifications for the width. Similarly if your linear layout is vertical, the subunits should have "0dp" height for layout_weight to work properly. - I just learned this myself so I thought I'd share.
@ayeshaarshad3403
@ayeshaarshad3403 2 жыл бұрын
Thanks for sharing
@MrIMacro
@MrIMacro 3 жыл бұрын
Can i add checkboxes to them?
@kenichimendoza8571
@kenichimendoza8571 3 жыл бұрын
Yes but no. ListView is deprecated. I suggest you use RecyclerView. And I think it is possible to just put checkbox.
@user-cl5wn9fz7f
@user-cl5wn9fz7f 3 жыл бұрын
@@kenichimendoza8571 recyclerview? Id like to know why you people aren't using jetpack compose yet
@priya_almond8864
@priya_almond8864 3 жыл бұрын
sir getFilter method is not working in costom adapter please reply how to make search ?????????????????????????????????????????????????????? please i m crying
@ankitgaur5226
@ankitgaur5226 7 жыл бұрын
Kindly make the custom list view tutorial with images thanks
@ankitgaur5226
@ankitgaur5226 7 жыл бұрын
Thanq so much sir
RecyclerView | Everything You Need to Know
25:07
Practical Coding
Рет қаралды 132 М.
Serve an XML or Compose UI at RUNTIME
8:03
CodingWithMitch
Рет қаралды 4,6 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 38 МЛН
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 8 МЛН
Advice from a Principal Software Engineer at Amazon (Steve Huynh)
22:45
RecyclerView Item Click | Best Practice Way
8:06
Practical Coding
Рет қаралды 93 М.
From Physics Student to Software Engineer
6:22
CodingWithMitch
Рет қаралды 11 М.
KMP vs. Flutter - Who Will Win The Cross-Platform Battle?
16:19
Philipp Lackner
Рет қаралды 40 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
Custom layouts and graphics in Compose
20:25
Android Developers
Рет қаралды 51 М.
How to make a Calculator in Android Studio | 2024
21:24
Easy Tuto
Рет қаралды 251 М.
Custom listView in android with item click
14:25
Android WorldClub
Рет қаралды 194 М.