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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:19:22+00:00 2026-06-11T00:19:22+00:00

I have a ListView and it should be populated with ArrayList of objects. ArrayList<BrowserClass>

  • 0

I have a ListView and it should be populated with ArrayList of objects.

ArrayList<BrowserClass> playListArr = new ArrayList<BrowserClass>();

and here is BrowserClass:

public class BrowserClass{
    String musicName = null;
    int musicId = 0;

    BrowserClass(String Name, int Id)
    {
        musicName = Name;
        musicId = Id;
    }

    public String getName()
    {
        return musicName;
    }

    public int getId()
    {
        return musicId;
    }

}

In order to populate ListView I am using following code:

ArrayAdapter<BrowserClass> plAdapter = new ArrayAdapter<BrowserClass>(this, android.R.layout.simple_list_item_1, playListArr);
myListView.setAdapter(plAdapter);

But the listView is showing some garbage value. I need to display only the names(getname() in browser class). I can achieve this using Custom Listview, BaseAdapter. But i want to implement it without using BaseAdapter.

  • 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-11T00:19:23+00:00Added an answer on June 11, 2026 at 12:19 am

    like this :

    Product.java

    public class Product {
    private int id;
    private String name;
    private double price;
    
    public Product(){
        super();
    }
    
    public Product(int id, String name, double price) {
        super();
        this.id = id;
        this.name = name;
        this.price = price;
    }
    
    @Override
    public String toString() {
        return this.id + ". " + this.name + " [$" + this.price + "]";
    }
    }
    

    MainActivity

    public class MainActivity extends Activity {
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        ListView listView1 = (ListView) findViewById(R.id.listView1);
    
        Product[] items = { 
            new Product(1, "Milk", 21.50), 
            new Product(2, "Butter", 15.99), 
            new Product(3, "Yogurt", 14.90), 
            new Product(4, "Toothpaste", 7.99), 
            new Product(5, "Ice Cream", 10.00), 
        };
    
        ArrayAdapter<Product> adapter = new ArrayAdapter<Product>(this,
                    android.R.layout.simple_list_item_1, items);
    
        listView1.setAdapter(adapter);
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display a ListView in table format. The ListView should have rows
I have a WPF ListView that should be extended with an always visible footer.
I have a listview that's populated by rows that get their data from a
I have the following problem. My main activity consists of a ListView populated with
I have a ListView with custom adapter which is populated from local sqlite database.
I have a ListView in my activity that is populated from a database Cursor
I have a lazy-loading ListView populated with images gotten over the network. The list
I have a populated ListView with custom adapter and my objective is to download
The title pretty much says it all. I have a listview being populated by
So, I have my onCreate method here for populating a ListView with user installed

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.