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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:20:51+00:00 2026-06-17T18:20:51+00:00

I cant get my data to display in ListView. I have removed all unnecessary

  • 0

I cant get my data to display in ListView. I have removed all unnecessary code to keep this simple. The program works fine, but the only data that is displayed is “Model.Locations @ 421ec04eo” Why is this happening?

PinPoint Class

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.locations);

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

        ArrayList<Locations> items = new ArrayList<Locations>();
        Locations sr1 = new Locations();
        for (int i = 0; i < 15; i++) 
        {
            sr1.setAdress("Blablabla");
            sr1.setTitle("Home");
            sr1.setDistance("200m");
            items.add(sr1);
        }

        ArrayAdapter<Locations> adapter = new ArrayAdapter<Locations>(this,
                android.R.layout.simple_list_item_multiple_choice, items);

        listView1.setAdapter(adapter);
    }
}

Location class

    package Model;


    public class Locations 
    {
    int midlat;
    int midlong;
    String title;
    String adress;
    String distance;

    public int getMidlat() {
        return midlat;
    }


    public String getDistance() {
        return distance;
    }


    public void setDistance(String distance) {
        this.distance = distance;
    }


    public void setMidlat(int i) {
        this.midlat = i;
    }


    public int getMidlong() {
        return midlong;
    }


    public void setMidlong(int midlong) {
        this.midlong = midlong;
    }


    public String getTitle() {
        return title;
    }


    public void setTitle(String title) {
        this.title = title;
    }


    public String getAdress() {
        return adress;
    }


    public void setAdress(String adress) {
        this.adress = adress;
    }


    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return super.toString();
    }
}

locations XML.FILE

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

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:text="Button" />

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    </ListView>

    <TextView
        android:id="@+id/toptext"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:gravity="center_vertical" />

    <TextView
        android:id="@+id/bottomtext"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:ellipsize="marquee"
        android:singleLine="true" />

</RelativeLayout>
  • 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-17T18:20:52+00:00Added an answer on June 17, 2026 at 6:20 pm

    You need to override the toString() method of your custom type, which you started to do, but then just called the super which negates the purpose of overriding it in the first place.

    Make the toString() return what you want the arrayadapter to display in the ListView i.e.

    @Override
    public String toString(){
      return title + address + distance;
    }
    

    Of course, this is just an example, you can implement it to fit your needs.

    Also, the reason is because ArrayAdapter<T> by default calls the toString() method of the custom type to populate the TextView in the current row of the ListView. If you need the list to show something special above what you can put together in the overrided toString method you will have to create a custom adapter.

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

Sidebar

Related Questions

So I have been trying to get a ListView to display data from a
I'm writing a simple Abstract Data Type for fractions and I cant even get
Cant get this script to work with my menu really have tried everything any
This is probably a simple one but I cant get my head around it.
This is driving me nuts. I can't seem to get the data template within
I cant get jquery's date picker to work on my page. I have a
Probably I cant get more dumb, but seriously this is the first time I
i created a nsarraycontroller to display its data on my nstableview. this is working.
I have implemented an application to get the data from local mobile SQLite db
I have news application that needs to download data from the url and display

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.