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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:12:40+00:00 2026-06-05T03:12:40+00:00

I’m having some trouble figuring something out that should be quite easy and straight

  • 0

I’m having some trouble figuring something out that should be quite easy and straight forward. I have an activity that has a few Views in it including a ListView that currently is not populated.

How do you programmatically get a reference to that ListView and then set the items, each item being a TextView with the content then being XML String-Array items?

Getting reference I suppose is like this:

ListView incomeList = (ListView) findViewById(R.id.incomeList);

Also I have a this code in my strings.xml(Want to populate list with this array):

<string-array name="testArray">
   <item>Item1</item>
   <item>Item2</item>
   <item>Item3</item>
   <item>Item4</item>
   <item>Item5</item>
</string-array>

And then lastly I have this other layout xml file that I should have according to all the tuts out there. list_item.xml

<?xml version="1.0" ebcoding="utf-8">
<TextView xmlns:android="blablabla..."
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:padding="10dp"
   android:textSize="16sp"
</TextView>

All of the tutorials I followed on the web though is helpful if a ListView is the only View in your activity. Whereas in my case I have quite a few Views including buttons, textviews etc etc.(If this might be helpful to know). Also do I extend my class with ListActivity or since I have other views in there, just extend normally with Activity?

  • 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-05T03:12:42+00:00Added an answer on June 5, 2026 at 3:12 am

    You don’t need to extend ListActivity. Just extend a regular activity.

    Steps:

    A) get your ListView. You’re doing it right in your question.

    B) create an ArrayAdapter. You must pass a Context (if you do it on the Activity, pass that Activity), an int representing a Layout which ONLY contains a TextView (Like the one in your question), and a String[] containing all the items you need.

    Should look like this:

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, getResources().getStringArray(R.array.testArray);
    

    C) lv.setAdapter(adapter);

    Pretty straightforward.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.