{"id":13731,"date":"2020-01-30T08:27:54","date_gmt":"2020-01-30T08:27:54","guid":{"rendered":"https:\/\/ittutorial.org\/?p=13731"},"modified":"2020-02-01T13:06:06","modified_gmt":"2020-02-01T13:06:06","slug":"android-programming-12-arrayadapter","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/android-programming-12-arrayadapter\/","title":{"rendered":"Android Programming -12 ArrayAdapter"},"content":{"rendered":"<p>H\u0131 guys in this tutorial \u00a0We will see the use of arrayadapters in android programming.<\/p>\n<p>In my previous tutorial, I talked about the \u00a0listview component. If you have not read it yet, I recommend you read it first.<\/p>\n<p><a href=\"https:\/\/ittutorial.org\/android-programming-11-listview-component\/\">https:\/\/ittutorial.org\/android-programming-11-listview-component\/<\/a><\/p>\n<p style=\"margin: 0in;font-family: Calibri;font-size: 11.0pt\">If you remember from the previous tutorial, we added the string values we wanted to show in listview into the arraylist. Today we will do the part showing the values we added the arraylist in listview. we will do this with ArrayAdapter.<\/p>\n<pre>package com.example.mac.makale;\r\n\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.os.Bundle;\r\nimport android.widget.ArrayAdapter;\r\nimport android.widget.ListView;\r\nimport java.util.ArrayList;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n\r\nListView listView;\r\nArrayList&lt;String&gt; arrayList;\r\nArrayAdapter&lt;String&gt; arrayAdapter;\r\n\r\n@Override\r\n\u00a0\u00a0\u00a0 protected void onCreate(Bundle savedInstanceState) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 super.onCreate(savedInstanceState);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 setContentView(R.layout.activity_main);\r\n\r\nlistView=(ListView)findviewByid(R.id.listview_exmple);\r\n\r\narrayList=new ArrayList&lt;&gt;();\r\n\r\narrayList.add(\"Bu\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 arrayList.add(\"bir\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 arrayList.add(\"Android\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 arrayList.add(\"E\u011fitim\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 arrayList.add(\"Serisidir..\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0 arrayAdapter=new ArrayAdapter&lt;&gt;(YeniSayfaActivity.this,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 android.R.id.simple_list_item_1,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 arrayList);\r\n\r\nlistView.setAdapter(arrayAdapter);\r\n\r\n}\r\n}<\/pre>\n<p style=\"margin-top: 0pt;margin-bottom: 15pt;font-family: Calibri;font-size: 11.0pt\">If we examine the code;<\/p>\n<p style=\"margin-top: 0pt;margin-bottom: 15pt;font-family: Calibri;font-size: 11.0pt\">We define te global variables first , then we start writing our code in the oncreate method.We add the string value we want into add into the arraylist, than we define the adapter. we create the adapter with 3 parameter.<\/p>\n<p style=\"margin-top: 0pt;margin-bottom: 15pt;font-family: Calibri;font-size: 11.0pt\">The first parameter is the context, the second parameter is the part where the adjustments are made about how each line of the list will appear, and the last part is the part where the arraylist we want to show in listview is specified.<\/p>\n<p style=\"margin-top: 0pt;margin-bottom: 15pt;font-family: Calibri;font-size: 11.0pt\">After setting the adapter according to the parameter values mentioned above, we set it with the adapter variable we set thanks to the setAdapter method of listview.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>H\u0131 guys in this tutorial \u00a0We will see the use of arrayadapters in android programming. In my previous tutorial, I talked about the \u00a0listview component. If you have not read it yet, I recommend you read it first. https:\/\/ittutorial.org\/android-programming-11-listview-component\/ If you remember from the previous tutorial, we added the string values we wanted to show &hellip;<\/p>\n","protected":false},"author":44,"featured_media":13732,"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-13731","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\/01\/adapter-listview.png","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13731","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=13731"}],"version-history":[{"count":2,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13731\/revisions"}],"predecessor-version":[{"id":13735,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13731\/revisions\/13735"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media\/13732"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=13731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=13731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=13731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}