Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8315829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:13:13+00:00 2026-06-08T21:13:13+00:00

Can anyone explain android.R.layout.simple_list_item_1 and android.R.layout.simple_list_item_2 in arrayadapter in Android? I know in android.R.layout.simple_list_item_1

  • 0

Can anyone explain android.R.layout.simple_list_item_1 and android.R.layout.simple_list_item_2 in arrayadapter in Android?

I know in android.R.layout.simple_list_item_1 and android.R.layout.simple_list_item_2 are layouts that are defined by Android itself.

android.R.layout.simple_list_item_1 only contains one TextView, but android.R.layout.simple_list_item_2 contains two TextViews.

I would like an example for android.R.layout.simple_list_item_2. How do I show two TextViews in a ListView using adapter?

My code is

package com.app.listview;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ExampleListViewActivity extends Activity {

    private String[] nameArr = new String[] {"Arun", "Anil", "Ankit", "Manoj"};
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ListView listView = (ListView) findViewById(R.id.lv);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                                                                android.R.layout.simple_list_item_1,
                                                                android.R.id.text1,
                                                                nameArr);
        listView.setAdapter(adapter);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:13:14+00:00Added an answer on June 8, 2026 at 9:13 pm

    The difference is the following. simple_list_item_1 contains only a TextView, whereas simple_list_item_2 has two inside a subclass of RelativeLayout. These are both taken from Jelly Bean.

    simple_list_item_1

    <?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2006 The Android Open Source Project
    
         Licensed under the Apache License, Version 2.0 (the "License");
         you may not use this file except in compliance with the License.
         You may obtain a copy of the License at
    
              http://www.apache.org/licenses/LICENSE-2.0
    
         Unless required by applicable law or agreed to in writing, software
         distributed under the License is distributed on an "AS IS" BASIS,
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         See the License for the specific language governing permissions and
         limitations under the License.
    -->
    
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceListItemSmall"
        android:gravity="center_vertical"
        android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
        android:paddingRight="?android:attr/listPreferredItemPaddingRight"
        android:minHeight="?android:attr/listPreferredItemHeightSmall"
    />
    

    simple_list_item_2

    <?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2006 The Android Open Source Project
    
         Licensed under the Apache License, Version 2.0 (the "License");
         you may not use this file except in compliance with the License.
         You may obtain a copy of the License at
    
              http://www.apache.org/licenses/LICENSE-2.0
    
         Unless required by applicable law or agreed to in writing, software
         distributed under the License is distributed on an "AS IS" BASIS,
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         See the License for the specific language governing permissions and
         limitations under the License.
    -->
    
    <TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:mode="twoLine"
    >
    
        <TextView android:id="@android:id/text1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
        android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft"
        android:layout_marginTop="8dip"
            android:textAppearance="?android:attr/textAppearanceListItem"
        />
    
        <TextView android:id="@android:id/text2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/text1"
        android:layout_alignLeft="@android:id/text1"
            android:textAppearance="?android:attr/textAppearanceSmall"
        />
    
    </TwoLineListItem>
    

    According to the docs for ArrayAdapter:

    By default this class expects that the provided resource id references
    a single TextView.

    So by default, an ArrayAdapter doesn’t automatically fill in multiple TextView instances. You can, however, override the getView() method and fill in the two TextViews that appear in R.layout.simple_list_item_2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain me that how can i get the configuration of Android device
Can anyone explain the question mark means in Android XML attributes? <TextView style=?android:attr/windowTitleStyle More
I am trying to boot android in beagleboard.anyone can explain step by step to
Can anyone point me out or explain what is the difference between android Home
Can anyone explain me about each term that I have used in working with
can anyone explain me what does this feature gives me : android.hardware.faketouch.multitouch.distinct The description
Is it possible to use @fontface with Android? If so can anyone explain weher
Can anyone explain to me why this program: for(float i = -1; i <
Can anyone explain why here a = [] ? 1 : 2 a will
Can anyone explain me how to overpass these problems? Description Resource Path Location Type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.