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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:28:39+00:00 2026-05-27T17:28:39+00:00

I am trying to create a Listview with multiple strings. Right now I have

  • 0

I am trying to create a Listview with multiple strings.

Right now I have a function that it will do

       while(i <= 10){
           //GETS DATA FROM WEBPAGE ETC
           a = DATAFROMWEBPAGE1;
           b = DATAFROMWEBPAGE2;
           c = DATAFROMWEBPAGE3
       }

10 times with 10 different sections from the webpage and I wanted to put this in a list view with 3 textviews showing a, b, c. But I’m having a very hard time doing so.

  • 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-05-27T17:28:39+00:00Added an answer on May 27, 2026 at 5:28 pm

    You can write a custom ListAdapter to do this:

    MyAdapter adapter = new MyAdapter (this);
    for (int i = 0; i < 10; i++) {
        adapter.addAdapterItem(new AdapterItem("first", "second", "third");
    }
    view.setListAdapter(adapter);
    

    class AdapterItem:

    public class AdapterItem {
      public String first;
      pubilc String second;
      public String third;
    
      public AdapterItem(String first, String second, String third) {
        this.first = first;
        this.second = second;
        this.third = third;
      }
    }
    

    class MyAdapter:

    public class MyAdapter extends BaseAdapter {
    
    private List<AdapterItem> items;
    
    public void addAdapterItem(AdapterItem item) {
      items.add(item); 
    }
    
    public int getCount() {
      return items.size();
    }
    
    public Object getItem(int position) {
      return items.get(position);
    }
    
    public View getView(int position, View convertView, ViewGroup parent) 
      View rowView = getLayoutInflater().inflate(R.layout.rowLayout);
      TextView firstTextView = (TextView) rowView.findViewById(R.id.firstView);
      firstTextView.setText(items.get(postion).first);
      // do the same with second and third
      return rowView;
    }
    

    Layout:

    <LinearLayout android:Layout_width=".." android:layout_height="..">
      <TextView android:id="firstView" />
      <TextView android:id="secondView" />
      <TextView android:id="thirdView" />
    </LinearLayout>
    

    The code is not complete, just to give you the idea:

    -You create a new ListAdapter that handles your items

    • You can store your items in an extra class (AdapaterItem in this example) inside your adapter
    • Your ListAdapter implementation has to provide common methods like getCount() and getItem()
    • Within the getView(..) method you can return your custom view for each row. If you want to display 3 different text messages you have to define 3 Textviews in your layout and assign the strings in getView(..)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a ListView with items that have two lines of text,
I am trying to create a ListView that will be populated with the entries
I have a weird problem! I'm trying to create a listview with checkboxes. In
I am trying to create a listview loaded from rss feeds into a widget?
I'm trying to create a custom view (one that is not 100% listview, for
I'm trying to create a UserControl that contains a ListView and a number of
So I'm trying to create a screen which has a ListView and over that
I'm trying to create a simple chat layout. I have a ListView with transcriptMode=alwaysScroll
I'm trying to create a self-contained Winforms control called DragDropListView. It derives from ListView.
I'm trying to create a table with Listview and one of the fields I'm

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.