<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jenny Cookies on Medium]]></title>
        <description><![CDATA[Stories by Jenny Cookies on Medium]]></description>
        <link>https://medium.com/@jenniferjjenny?source=rss-8918aa4a62fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Nxpk19NR7r-Aw9KE.</url>
            <title>Stories by Jenny Cookies on Medium</title>
            <link>https://medium.com/@jenniferjjenny?source=rss-8918aa4a62fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:54:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jenniferjjenny/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding and creating custom adapters for Android’s ListView]]></title>
            <link>https://medium.com/@jenniferjjenny/understanding-and-creating-custom-adapters-for-androids-listview-81ffefbb1fcc?source=rss-8918aa4a62fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/81ffefbb1fcc</guid>
            <category><![CDATA[listview]]></category>
            <category><![CDATA[custom-adapters]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Jenny Cookies]]></dc:creator>
            <pubDate>Wed, 10 May 2017 00:57:58 GMT</pubDate>
            <atom:updated>2017-05-11T02:45:27.833Z</atom:updated>
            <content:encoded><![CDATA[<p>As a recent Computer Science graduate and Android Developer, I continuously find myself struggling to learn and adapt to the point where I’m outside of my comfort zone. I continuously struggle to obtain things in a “quick” manner, and learn new things about myself everyday. This week, my biggest challenge was tackling ListViews and Custom Adapters. I admit that I haven’t worked with ListViews too often, but I do push myself to learn as much as I can about it. Not just because it’s a very useful and widely-used view group, but because it’s essential to my learning.</p><p>I proudly created a ListView and came across a bug that made my list’s height very small. I eventually (with the help of a fellow coder, AKA my boyfriend) realized that I had a scrollview preventing my listview from taking up the “match_parent” height. “Great,” I thought. “Now I should be good!” Sike! I later came across another bug that caused my listview items to duplicate while I scrolled down the list. Obviously, this wasn’t supposed to happen and started looking for the possible causes. I later tested the ArrayAdapter class and noticed that the list was working fine as I scrolled. However, that’s when I realized that the problem laid upon the custom adapter I had previously created.</p><p>Why a custom adapter? It was impossible to display listitems with both an imageview and textview right next to each other. It was much more plausible to create a custom adapter that would inherit properties from the BaseAdapter class, along with easily add items to my list using an ArrayList (cause they’re much easier to implement and work with than an Array, at least in my case). Anyway, I looked at different tutorials (StackOverFlow included) and built my custom adapter based on that. That’s when I noticed that something was wrong. When I added items, they would end up duplicating as I scrolled down the list and as I loaded the fragment. I then looked through my code and realized my problem was in my adapter’s getView() method. The getView() method was duplicating the items in the listview because the view was not being refreshed.</p><p>I later found out, through StackOverFlow searches, that listviews “recycle” items when the same view is assigned to each item in the list. I fixed this issue by instantiating a View variable that would create a view everytime an item is added, and I also created a ViewHolder class that would store both my imageview and textview elements and then display them after each value has been set. Everytime I add something to the list, the adapter would automatically create a new view and then display the current item. This, folks, is what I call a big pain in my ass. Thank you, Google, for creating such useful Android examples on your guides *Insert sarcastic tone here.*</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81ffefbb1fcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>