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 8805217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:48:32+00:00 2026-06-14T01:48:32+00:00

I’ve got a TextView and it’s getting a list in it. public class Home

  • 0

I’ve got a TextView and it’s getting a list in it.

public class Home extends ListActivity {
ListView listView;
static final String[] Liste = {"a", "b", "c"};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTitle("CalcPlus");
    listView = getListView();
    //Own row layout
    listView.setAdapter(new ArrayAdapter<String>(this,
                R.layout.activity_home, R.id.text, Liste));
    //listView.setOnItemClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_home, menu);
    return true;
}

Now I want a small grey description of the list item, like here:
enter image description here

I read these tutorials: 1 and 2 but I have to admit, I don’t understand what they say.
Can someone explain how to use them? Do I have to remove my TextView/List I have now? Is there another way to make a little description, without using a custom ListView?

Here’s my xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ListView android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:divider="#b5b5b5"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_selector" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=""
android:textAllCaps="false"
android:textSize="22dp"
android:textStyle="bold"
android:layout_marginBottom="50dp" 
android:layout_marginTop="50dp" 
android:layout_marginLeft="2dp"/>

I don’t really use the listview “list”, just for testing purposes.

  • 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-14T01:48:33+00:00Added an answer on June 14, 2026 at 1:48 am

    You need to understand that the following line

    listView.setAdapter(new ArrayAdapter<String>(this,
                R.layout.activity_home, R.id.text, Liste));
    

    means that you want to use layout.activity_home.xml for each item’s view of your list.
    So I don’t see why there is a ListView inside it…

    By default the ArrayAdapter uses one single text field per item. If you want a more complex item layout, you need to override the getView() method of your adapter.

    Here is the simplest solution I can think of:

    In Home.java:

    public class Home extends ListActivity {
    ListView listView;
    static final String[] Liste = {"a", "b", "c"};
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        setTitle("CalcPlus");
    
        listView = getListView();
    
        listView.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.text, Liste) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View view = super.getView(position, convertView, parent);
    
                String item = getItem(position);
    
                TextView subTitleView = (TextView) view.findViewById(R.id.subtitle);
                subTitleView.setText("Subtitle of " + item);
    
                return view;
            }
        });
    }
    }
    

    And layout/list_item.xml:

    <?xml version="1.0" encoding="utf-8"?>
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="10dp" >
    
    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text=""
        android:textAllCaps="false"
        android:textSize="22dp"
        android:textStyle="bold" />
    
    <TextView
        android:id="@+id/subtitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text=""
        android:textAllCaps="false"
        android:textSize="16dp"
        android:textStyle="normal" />
    
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
i got an object with contents of html markup in it, for example: string
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Specifically, suppose I start with the string string =hello \'i am \' me And
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.