0

When we build a ListView in android studio, we need to use an ArrayAdapter.

What is the task of second argument in constructor of ArrayAdapter ?

I cannot understand what is android.R.layout.simple_list_item_1 used for ?

gktg1414
  • 107
  • 2
  • 9
  • Possible duplicate of [What is "android.R.layout.simple\_list\_item\_1"?](https://stackoverflow.com/questions/3663745/what-is-android-r-layout-simple-list-item-1) – Manohar Jul 20 '17 at 16:25

5 Answers5

0

This layout describe how the item list looks like.Maybe you want every item contain a text view and image.You should specify these details in this layout.

Karim
  • 322
  • 1
  • 10
0

android.R.layout.simple_list_item_1 is a layout in which the data from your ArrayAdapter gets populated(added).

Ojas Chimane
  • 104
  • 10
0

This is the id of the layout that you need to use for populating each of the item in the list. If it says android.R.layout that means you are going to use one of the standard android layouts. simple_list_item_1 This is the name of the file which will populate each row of the list. try changing this to simple_list_item_2 to see how the layout in list changes.

You can also use your custom adaptors and custom layouts(which would be in majority of the cases in day to day apps).

For full list of standard layouts available Go here

Kapil G
  • 4,081
  • 2
  • 20
  • 32
0

This argument defines how list items would appear in ListView, There are many layouts you can also try them out or you can make your own custom layout to modify apperance of listitems in Listview by using CustomAdapter.

Shivam Arora
  • 354
  • 2
  • 8
0

1.create custom layout name custom_layout.xml & paste bellow code

 <?xml version="1.0" encoding="utf-8"?>
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="16sp" >
</TextView>
  1. Use like R.layout.custom_layout instead of android.R.layout.simple_list_item_1
Enamul Haque
  • 4,789
  • 1
  • 37
  • 50