{"id":13756,"date":"2020-02-12T08:39:53","date_gmt":"2020-02-12T08:39:53","guid":{"rendered":"https:\/\/ittutorial.org\/?p=13756"},"modified":"2020-02-12T11:35:50","modified_gmt":"2020-02-12T11:35:50","slug":"android-programming-13-custom-listview","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/android-programming-13-custom-listview\/","title":{"rendered":"Android Programming -13 Custom Listview"},"content":{"rendered":"<p>Hi guys in this tutorial \u00a0We will see the custom listview.<\/p>\n<p>In my previous tutorial, I talked about the use of adapters in android programming. If you have not read it yet, I recommend you read it first.<\/p>\n<p><!--more--><\/p>\n<p><a href=\"https:\/\/ittutorial.org\/android-programming-12-arrayadapter\/\">Android Programming -12 ArrayAdapter<\/a><\/p>\n<p>In standard adapter use, we could not interfere with listview items in any way. But if we define our own adapter, we know that the listview implements the design we want.<\/p>\n<p>Think about it, you are looking for hotels for a holiday. Each hotel\u00a0 should have small photo, name, addres how many stars, etc. Because of we will show all hotels, we need to use listview component.\u00a0 Since we want to show more than one feature of each hotel in one line, we need to customize our adapter.<\/p>\n<p>when we want to customize the our adapter, we need to create a java class, a layout and a java adapter class. we code\u00a0 layout as we want a line of listview to be.<\/p>\n<p>&nbsp;<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n\r\n\u00a0\u00a0\u00a0 android:orientation=\"vertical\"\r\n\r\n\u00a0\u00a0\u00a0 android:layout_width=\"match_parent\"\r\n\r\n\u00a0\u00a0\u00a0 android:layout_height=\"match_parent\"\r\n\r\n\u00a0\u00a0\u00a0 android:layout_margin=\"20dp\"&gt;\r\n\r\n&lt;LinearLayout\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_width=\"match_parent\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_height=\"wrap_content\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:orientation=\"vertical\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:id=\"@+id\/linearLayout\"&gt;\r\n\r\n&lt;ImageView\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:id=\"@+id\/txt\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_width=\"match_parent\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_height=\"230dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:src=\"@drawable\/siyah_ev\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_margin=\"20dp\" \/&gt;\r\n\r\n&lt;LinearLayout\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_width=\"match_parent\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_height=\"wrap_content\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:orientation=\"horizontal\"&gt;\r\n\r\n&lt;TextView\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:id=\"@+id\/yorum\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_width=\"200dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_height=\"40dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_marginLeft=\"20dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:text=\"K\u00fcbra Hebesss\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:textColor=\"#111\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_marginTop=\"10dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:fontFamily=\"@string\/confirm_recovery_body\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:textSize=\"15dp\" \/&gt;\r\n\r\n&lt;Button\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:id=\"@+id\/like\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_width=\"30dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_height=\"30dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_marginLeft=\"50dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_marginTop=\"15dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:background=\"@drawable\/like_white\" \/&gt;\r\n\r\n&lt;TextView\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:id=\"@+id\/like_count\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_width=\"30dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:text=\"12\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:textColor=\"#111\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_height=\"35dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_marginLeft=\"10dp\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android:layout_marginTop=\"14dp\"\/&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/LinearLayout&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/LinearLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-13757 size-full\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2020\/02\/https-ittutorial-org-wp-content-uploads-2019-04-.png\" alt=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/Ekran-Resmi-2019-04-27-21.49.09-193x300.png\" width=\"193\" height=\"300\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>The output of our sample layout code is as above.<\/p>\n<p>&nbsp;<\/p>\n<p>You can think of this page as the main screen of instagram . we add an imageview to our picture to show the picture we will share.\u00a0 Below the photo, we use a textview to see the name of the sharer, a button for followers to know like, and a textview showing the number of likes. We set the margin and padding features to the necessary components so that we can make the design as we want.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi guys in this tutorial \u00a0We will see the custom listview. In my previous tutorial, I talked about the use of adapters in android programming. If you have not read it yet, I recommend you read it first.<\/p>\n","protected":false},"author":44,"featured_media":13769,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[7017,7011,7007,7005,7015,4746,7009,7008,7010,7024,3319,7021,7026,7016,7022,7025,7018,7019,7020,7006,7014,7023,7012,7013],"class_list":["post-13756","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-android","tag-android-app-development","tag-android-app-development-software","tag-android-button-color-xml","tag-android-coding","tag-android-development-basics","tag-android-programming","tag-android-programming-language","tag-android-programming-tutorial","tag-android-programming-with-java","tag-android-project","tag-android-studio","tag-android-studio-basic-example","tag-android-studio-basic-projects","tag-android-studio-first-app","tag-android-studio-lessons","tag-android-studio-projects","tag-android-studio-tutorial","tag-android-studio-tutorial-for-beginners","tag-android-studio-tutorial-point","tag-android-xml-coding","tag-create-mobile-app-without-coding","tag-java-android-developer","tag-mobil-app-maker","tag-mobile-application-make"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/ittutorial.org\/wp-content\/uploads\/2020\/02\/Android-Studio.png","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/comments?post=13756"}],"version-history":[{"count":1,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13756\/revisions"}],"predecessor-version":[{"id":13758,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13756\/revisions\/13758"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media\/13769"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=13756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=13756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=13756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}