{"id":1810,"date":"2013-01-20T15:38:52","date_gmt":"2013-01-20T13:38:52","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=1810"},"modified":"2013-01-30T19:06:04","modified_gmt":"2013-01-30T17:06:04","slug":"android-listview-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/","title":{"rendered":"Android ListView Example"},"content":{"rendered":"<p>One of the most usefull layouts in Android is the <span style=\"font-family: monospace;\">ListView<\/span>.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize the list, and you can populate it\u00a0dynamically\u00a0in your code.<\/p>\n<p>In this tutorial we are going to see how <code>ListView <\/code>and <code>ListActivity\u00a0<\/code>works. This tutorial has two parts. In the first part you are going to see the normal way to \u00a0display a <code>ListView<\/code>. In the second part we are going to create an customized <code>ListView <\/code>and for that we need a customized <code>ArrayAdapter<\/code>.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\nFor this tutorial, we will use the following tools in a Windows 64-bit platform:<\/p>\n<ol>\n<li>JDK 1.7<\/li>\n<li>Eclipse 4.2 Juno<\/li>\n<li>Android SKD 4.2<\/li>\n<\/ol>\n<h3>Create a new Android Project<\/h3>\n<p>Open Eclipse IDE and go to File -&gt; New -&gt; Project -&gt; Android -&gt; Android Application Project and click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/create-new-project6.jpg\"><img decoding=\"async\" title=\"create-new-project\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/create-new-project6.jpg\" alt=\"\" width=\"467\" height=\"460\" \/><\/a><\/p>\n<p>You have to specify the Application Name, the Project Name and the Package name in the appropriate text fields and then click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/create-new-project-attributes5.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1811\" title=\"create-new-project-attributes\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/create-new-project-attributes5.jpg\" alt=\"\" width=\"551\" height=\"443\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/create-new-project-attributes5.jpg 551w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/create-new-project-attributes5-300x241.jpg 300w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><\/a><\/p>\n<p>In the next window make sure the \u201cCreate activity\u201d option is selected in order to create a new activity for your project, and click Next. This is optional as you can create a new activity after creating the project, but you can do it all in one step.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/check-create-new-activity12.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1812\" title=\"check-create-new-activity\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/check-create-new-activity12.jpg\" alt=\"\" width=\"552\" height=\"483\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/check-create-new-activity12.jpg 552w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/check-create-new-activity12-300x262.jpg 300w\" sizes=\"(max-width: 552px) 100vw, 552px\" \/><\/a><\/p>\n<p>Select \u201cBlankActivity\u201d and click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/create-blanc-activity.jpg\"><img decoding=\"async\" title=\"create-blanc-activity\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/create-blanc-activity.jpg\" alt=\"\" width=\"535\" height=\"485\" \/><\/a><\/p>\n<p>You will be asked to specify some information about the new activity. \u00a0In the Layout Name text field you have to specify the name of the file that will contain the layout description of your app. In our case the file\u00a0<code>res\/layout\/main.xml<\/code>\u00a0will be created. Then, click Finish.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/create-new-activity-attributes3.jpg\"><img decoding=\"async\" title=\"create-new-activity-attributes\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/create-new-activity-attributes3.jpg\" alt=\"\" width=\"625\" height=\"452\" \/><\/a><\/p>\n<h3><span style=\"text-decoration: underline;\">Normal ListView Example<\/span><\/h3>\n<p>Now let&#8217;s begin with the first part.<\/p>\n<h3>1. Create a new xml Layout file<\/h3>\n<p>Go to the Package Explorer and right click on the\u00a0<code>res\/layout\u00a0<\/code>folder. Select New -&gt; Other -&gt; Android -&gt; Android XML Layout File. And click Next:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-xml-file.jpg\"><img decoding=\"async\" title=\"new-layout-xml-file\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-xml-file.jpg\" alt=\"\" width=\"517\" height=\"493\" \/><\/a><\/p>\n<p>Then specify the name of the file and the Layout type and click Finish:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-countries1.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1820\" title=\"new-layout-file-countries\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-countries1.jpg\" alt=\"\" width=\"475\" height=\"444\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-countries1.jpg 475w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-countries1-300x280.jpg 300w\" sizes=\"(max-width: 475px) 100vw, 475px\" \/><\/a><\/p>\n<p>As you will see in the Package Explorer the new\u00a0<code>\/res\/layout\/countries.xml<\/code>\u00a0file has been created:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-countries1.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1821\" title=\"package-explorer-countries\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-countries1.jpg\" alt=\"\" width=\"389\" height=\"457\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-countries1.jpg 389w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-countries1-255x300.jpg 255w\" sizes=\"(max-width: 389px) 100vw, 389px\" \/><\/a><\/p>\n<p>Open that file and paste the following code:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;TextView xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"\r\n    android:padding=\"10dp\"\r\n    android:textSize=\"18sp\" &gt;\r\n\r\n&lt;\/TextView&gt;<\/pre>\n<h3>2. Code<\/h3>\n<p>Go to the java file that contains the code of the activity\u00a0you&#8217;ve\u00a0just created:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file3.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1822\" title=\"package-explorer-source-file\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file3.jpg\" alt=\"\" width=\"437\" height=\"313\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file3.jpg 437w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file3-300x214.jpg 300w\" sizes=\"(max-width: 437px) 100vw, 437px\" \/><\/a><\/p>\n<p>And paste the following code:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.androidlistviewexample;\r\n\r\nimport android.app.ListActivity;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\nimport android.widget.AdapterView;\r\nimport android.widget.ArrayAdapter;\r\nimport android.widget.ListView;\r\nimport android.widget.TextView;\r\nimport android.widget.Toast;\r\nimport android.widget.AdapterView.OnItemClickListener;\r\n\r\npublic class MainActivity extends ListActivity {\r\n\r\n\tstatic final String[] COUNTRIES = new String[] { \"Greece\", \"Italy\", \"France\",\r\n\t\t\t\"Spain\", \"Germany\", \"Poland\", \"Romania\", \"Turkey\",\r\n\t\t\t\"Switzerland\", \"Netherlands\", \"Luxembourg\", \"Ukrain\" };\r\n\r\n\t@Override\r\n\tpublic void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\r\n\t\t\/\/ we don't need this\r\n\t\t\/\/ setContentView(R.layout.countries);\r\n\r\n\t\tsetListAdapter(new ArrayAdapter(this, R.layout.countries,COUNTRIES));\r\n\r\n\t\tListView listView = getListView();\r\n\t\tlistView.setTextFilterEnabled(true);\r\n\r\n\t\tlistView.setOnItemClickListener(new OnItemClickListener() {\r\n\t\t\tpublic void onItemClick(AdapterView parent, View view, int position, long id) {\r\n\r\n\t\t\t    \/\/ When clicked, show a toast with the TextView text\r\n\t\t\t    Toast.makeText(getApplicationContext(),\t((TextView) view).getText(), Toast.LENGTH_SHORT).show();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t}\r\n\r\n}<\/pre>\n<h3>3. Run the application<\/h3>\n<p>Go ahead and run the application to see how the layout looks on your emulator:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen13.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1823\" title=\"main-screen\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen13.jpg\" alt=\"\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen13.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen13-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>And if you click an item on the list:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/view-text1.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1824\" title=\"view-text\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/view-text1.jpg\" alt=\"\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/view-text1.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/view-text1-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<h3>Download Eclipse Project<\/h3>\n<p>This was the first part of the Android ListView Example. Download the Eclipse Project of the first part of this tutorial:\u00a0<a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/AndroidListViewExample_1.zip\">AndroidListViewExample_1.zip<\/a><\/p>\n<h3><span style=\"text-decoration: underline;\"><strong>Custom ListView Example<\/strong><\/span><\/h3>\n<p>For this part you can create a new Android Project if you want, but I&#8217;m going to use the old one.<\/p>\n<h3>1. Create the custom Layout<\/h3>\n<p>The first thing you have to do for this part is to create a new xml Layout file that will describe the Layout of our custom list.<\/p>\n<p>Go to the Package Explorer and right click on the\u00a0<code>res\/layout\u00a0<\/code>folder. Select New -&gt; Other -&gt; Android -&gt; Android XML Layout File. And click Next:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-xml-file.jpg\"><img decoding=\"async\" title=\"new-layout-xml-file\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-xml-file.jpg\" alt=\"\" width=\"517\" height=\"493\" \/><\/a><\/p>\n<p>Then specify the name of the file and the Layout type and click Finish:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-custom_list.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1825\" title=\"new-layout-file-custom_list\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-custom_list.jpg\" alt=\"\" width=\"497\" height=\"438\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-custom_list.jpg 497w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-layout-file-custom_list-300x264.jpg 300w\" sizes=\"(max-width: 497px) 100vw, 497px\" \/><\/a><\/p>\n<p>As you will see in the Package Explorer the new\u00a0<code>\/res\/layout\/custom_list.xml<\/code>\u00a0file has been created:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-custom-list.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1826\" title=\"package-explorer-custom-list\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-custom-list.jpg\" alt=\"\" width=\"360\" height=\"453\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-custom-list.jpg 360w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-custom-list-238x300.jpg 238w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><\/a><\/p>\n<p>Open that file and paste the following code:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:layout_width=\"wrap_content\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:padding=\"5dp\" &gt;\r\n\r\n    &lt;ImageView\r\n        android:id=\"@+id\/logo\"\r\n        android:layout_width=\"50px\"\r\n        android:layout_height=\"50px\"\r\n        android:layout_marginLeft=\"5px\"\r\n        android:layout_marginRight=\"20px\"\r\n        android:layout_marginTop=\"5px\" &gt;\r\n    &lt;\/ImageView&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/txt\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:text=\"@+id\/label\"\r\n        android:textSize=\"17sp\" &gt;\r\n    &lt;\/TextView&gt;\r\n\r\n&lt;\/LinearLayout&gt;<\/pre>\n<h3>2. Adding pictures in the appropriate project folder<\/h3>\n<p>As you would have noticed in the Package explorer, there are 4 folders that contain the image resources of the project :<\/p>\n<ol>\n<li><code>res\/drawable-hdpi<\/code><\/li>\n<li><code>res\/drawable-ldpi<\/code><\/li>\n<li><code>res\/drawable-mdpi<\/code><\/li>\n<li><code>res\/drawable-hdpi<\/code><\/li>\n<\/ol>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-drawble-folders.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1827\" title=\"package-explorer-drawble-folders\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-drawble-folders.jpg\" alt=\"\" width=\"360\" height=\"344\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-drawble-folders.jpg 360w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-drawble-folders-300x286.jpg 300w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><\/a><\/p>\n<p>You can copy the images you want to put in you\u2019re application in any one of these folders. \u00a0Android SDK will automatically\u00a0recognize any images you put on any one of these folders as drawable resources. So, copy the images\u00a0in the folder you want. If the image does not appear in the Package Explorer under the folder\u00a0you\u2019ve\u00a0copied it into, right click on the project name and select\u00a0Refresh. Now the image should be under the correct folder. As you can see,\u00a0I have four images in\u00a0<code>res\/drawable-hdpi<\/code>:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-pictutes.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1828\" title=\"package-explorer-pictutes\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-pictutes.jpg\" alt=\"\" width=\"314\" height=\"413\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-pictutes.jpg 314w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-pictutes-228x300.jpg 228w\" sizes=\"(max-width: 314px) 100vw, 314px\" \/><\/a><\/p>\n<h3>3. Create a Custom ArrayAdapter<\/h3>\n<p>To create a custom <code>ListView <\/code>you have to make your own <code>ArrayAdapter<\/code>. To do that you have to to create a new class that will extend <code>ArrayAdapter&lt;String&gt;<\/code>. In order to customize your <code>ListView <\/code>you have to override the <code>getView <\/code>method of the <code>ArrayAdapter<\/code>.<\/p>\n<p>Go to the Package Explorer and right click on the package (in our case com.javacodegeeks.android.androidlistviewexample):<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file3.jpg\"><img decoding=\"async\" title=\"package-explorer-source-file\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file3.jpg\" alt=\"\" width=\"437\" height=\"313\" \/><\/a><\/p>\n<p>Select New -&gt; Class. Put the\u00a0appropriate\u00a0attributes as shown in the\u00a0picture\u00a0below:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-class.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1829\" title=\"new-class\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-class.jpg\" alt=\"\" width=\"542\" height=\"631\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-class.jpg 542w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/new-class-257x300.jpg 257w\" sizes=\"(max-width: 542px) 100vw, 542px\" \/><\/a><\/p>\n<p>As you will see a new java file has been created:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file-new-adapter.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1830\" title=\"package-explorer-source-file-new-adapter\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file-new-adapter.jpg\" alt=\"\" width=\"432\" height=\"298\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file-new-adapter.jpg 432w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/package-explorer-source-file-new-adapter-300x206.jpg 300w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/a><\/p>\n<p>Open that file and paste the following code :<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.androidlistviewexample;\r\n\r\nimport com.javacodegeeks.android.androidlistviewexample.R;\r\nimport android.content.Context;\r\nimport android.view.LayoutInflater;\r\nimport android.view.View;\r\nimport android.view.ViewGroup;\r\nimport android.widget.ArrayAdapter;\r\nimport android.widget.ImageView;\r\nimport android.widget.TextView;\r\n\r\npublic class MyArrayAdapter extends ArrayAdapter {\r\n\tprivate final Context context;\r\n\tprivate final String[] values;\r\n\r\n\tpublic MyArrayAdapter(Context context, String[] values) {\r\n\t\tsuper(context, R.layout.custom_list, values);\r\n\t\tthis.context = context;\r\n\t\tthis.values = values;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic View getView(int position, View convertView, ViewGroup parent) {\r\n\t\tLayoutInflater inflater = (LayoutInflater) context\r\n\t\t\t.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r\n\r\n\t\tView rowView = inflater.inflate(R.layout.custom_list, parent, false);\r\n\t\tTextView textView = (TextView) rowView.findViewById(R.id.txt);\r\n\t\tImageView imageView = (ImageView) rowView.findViewById(R.id.logo);\r\n\t\ttextView.setText(values[position]);\r\n\r\n\t\t\/\/ Change icon based on name\r\n\r\n\t\tString s = values[position];\r\n\r\n\t\tif (s.equals(\"Red Android Logo\")) {\r\n\t\t\timageView.setImageResource(R.drawable.android_logo_red);\r\n\t\t} else if (s.equals(\"Green Android Logo\")) {\r\n\t\t\timageView.setImageResource(R.drawable.android_logo_green);\r\n\t\t} else if (s.equals(\"Yellow Android Logo\")) {\r\n\t\t\timageView.setImageResource(R.drawable.android_logo_yellow);\r\n\t\t}\r\n\r\n\t\treturn rowView;\r\n\t}\r\n}<\/pre>\n<p>Now go to\u00a0<code>MainActivity.java<\/code> file and paste the following code :<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.androidlistviewexample;\r\n\r\nimport android.app.ListActivity;\r\nimport android.os.Bundle;\r\nimport android.widget.ListView;\r\nimport android.widget.Toast;\r\nimport android.view.View;\r\n\r\npublic class MainActivity extends ListActivity {\r\n\r\n\tstatic final String[] Android_logos = \r\n               new String[] { \"Red Android Logo\", \"Green Android Logo\", \"Yellow Android Logo\"};\r\n\r\n\t@Override\r\n\tpublic void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\r\n\t\tsetListAdapter(new MyArrayAdapter(this, Android_logos));\r\n\t}\r\n\r\n\t@Override\r\n\tprotected void onListItemClick(ListView l, View v, int position, long id) {\r\n\r\n\t\tString selectedValue = (String) getListAdapter().getItem(position);\r\n\t\tToast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();\r\n\t}\r\n}<\/pre>\n<h3>4. Run the application<\/h3>\n<p>This is the main screen of our Application:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen-custom.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1831\" title=\"main-screen-custom\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen-custom.jpg\" alt=\"\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen-custom.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/main-screen-custom-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Now, when you click on an item:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/item-clicked.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1832\" title=\"item-clicked\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/item-clicked.jpg\" alt=\"\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/item-clicked.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/item-clicked-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<h3>Download Eclipse Project<\/h3>\n<p>This was the second part of the Android ListView Example. Download the Eclipse Project of the second part of this tutorial:\u00a0<a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/01\/AndroidListViewExample_2.zip\">AndroidListViewExample_2.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most usefull layouts in Android is the ListView.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize the list, and you can populate it\u00a0dynamically\u00a0in your code. In this tutorial we are going to see how ListView and ListActivity\u00a0works. This tutorial has two parts. In the first part you &hellip;<\/p>\n","protected":false},"author":7,"featured_media":1202,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[309],"tags":[265,291,290,267],"class_list":["post-1810","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-listview","tag-android-core","tag-android-listactivity","tag-android-listview","tag-android-ui"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android ListView Example<\/title>\n<meta name=\"description\" content=\"One of the most usefull layouts in Android is the ListView.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android ListView Example\" \/>\n<meta property=\"og:description\" content=\"One of the most usefull layouts in Android is the ListView.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-01-20T13:38:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-01-30T17:06:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ilias Tsagklis\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ilias Tsagklis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/\"},\"author\":{\"name\":\"Ilias Tsagklis\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/ca18b1aa108e3bfadf717e563e0a7a6e\"},\"headline\":\"Android ListView Example\",\"datePublished\":\"2013-01-20T13:38:52+00:00\",\"dateModified\":\"2013-01-30T17:06:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/\"},\"wordCount\":805,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"keywords\":[\"Android Core\",\"Android ListActivity\",\"Android ListView\",\"Android UI\"],\"articleSection\":[\"ListView\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/\",\"name\":\"Android ListView Example\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"datePublished\":\"2013-01-20T13:38:52+00:00\",\"dateModified\":\"2013-01-30T17:06:04+00:00\",\"description\":\"One of the most usefull layouts in Android is the ListView.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"core\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"ui\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"ListView\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/listview\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Android ListView Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/ca18b1aa108e3bfadf717e563e0a7a6e\",\"name\":\"Ilias Tsagklis\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/Ilias-Tsagklis_avatar_1454249217-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/Ilias-Tsagklis_avatar_1454249217-96x96.jpg\",\"caption\":\"Ilias Tsagklis\"},\"description\":\"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"http:\/\/www.iliastsagklis.com\/\",\"https:\/\/www.linkedin.com\/in\/iliastsagklis\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/ilias-tsagklis\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android ListView Example","description":"One of the most usefull layouts in Android is the ListView.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/","og_locale":"en_US","og_type":"article","og_title":"Android ListView Example","og_description":"One of the most usefull layouts in Android is the ListView.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize","og_url":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-01-20T13:38:52+00:00","article_modified_time":"2013-01-30T17:06:04+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","type":"image\/jpeg"}],"author":"Ilias Tsagklis","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Ilias Tsagklis","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/"},"author":{"name":"Ilias Tsagklis","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/ca18b1aa108e3bfadf717e563e0a7a6e"},"headline":"Android ListView Example","datePublished":"2013-01-20T13:38:52+00:00","dateModified":"2013-01-30T17:06:04+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/"},"wordCount":805,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","keywords":["Android Core","Android ListActivity","Android ListView","Android UI"],"articleSection":["ListView"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/","url":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/","name":"Android ListView Example","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","datePublished":"2013-01-20T13:38:52+00:00","dateModified":"2013-01-30T17:06:04+00:00","description":"One of the most usefull layouts in Android is the ListView.\u00a0ListView allows you to arrange your items in a\u00a0scrollable\u00a0list. Of course you can customize","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/listview\/android-listview-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/"},{"@type":"ListItem","position":3,"name":"core","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/"},{"@type":"ListItem","position":4,"name":"ui","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/"},{"@type":"ListItem","position":5,"name":"ListView","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/ui\/listview\/"},{"@type":"ListItem","position":6,"name":"Android ListView Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/ca18b1aa108e3bfadf717e563e0a7a6e","name":"Ilias Tsagklis","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/Ilias-Tsagklis_avatar_1454249217-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/Ilias-Tsagklis_avatar_1454249217-96x96.jpg","caption":"Ilias Tsagklis"},"description":"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.","sameAs":["http:\/\/www.iliastsagklis.com\/","https:\/\/www.linkedin.com\/in\/iliastsagklis"],"url":"https:\/\/examples.javacodegeeks.com\/author\/ilias-tsagklis\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1810"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1810\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1202"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}