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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:48:28+00:00 2026-06-02T21:48:28+00:00

This is my java list. private void filldata() { ListView lv = (ListView) findViewById(android.R.id.list);

  • 0

This is my java list.

private void filldata() {
    ListView lv = (ListView) findViewById(android.R.id.list);

    String[] from = new String[] { comment, commentdate, commentposter };
    int[] to = new int[] { R.id.text_comment, R.id.text_commentdate,
            R.id.text_commentposter };
    List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < 5; i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(comment, "testing 1");
        map.put(commentdate, "testing 2");
        map.put(commentposter, "testing 3");
        fillMaps.add(map);
    }
    SimpleAdapter adapter = new SimpleAdapter(this, fillMaps,
            R.layout.newscommentlist, from, to);
    lv.setAdapter(adapter);
}

The output given to me were

testing 3

testing 3

testing 3

but what i want was

testing 1

testing 2

testing 3

How to achieve what i expect?

Updated:

This is newscommentlist.xml

?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff" >

<TextView
    android:id="@+id/text_commentdate"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="10px"
    android:layout_marginTop="10px"
    android:gravity="right"
    android:textColor="#ff0000"
    android:textSize="20px" />

<TextView
    android:id="@+id/text_comment"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10px"
    android:layout_marginRight="10px"
    android:layout_marginTop="10px"
    android:gravity="fill_horizontal"
    android:textColor="#000000"
    android:textSize="30px" />

<TextView
    android:id="@+id/text_commentposter"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10px"
    android:layout_marginRight="10px"
    android:layout_marginTop="10px"
    android:gravity="right"
    android:textColor="#000000"
    android:textSize="35px" />

This is newscomments.xml

<ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10px" >
    </ListView>
  • 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-02T21:48:30+00:00Added an answer on June 2, 2026 at 9:48 pm
    private void filldata() {
        ListView lv = (ListView) findViewById(android.R.id.list);
    
        String[] from = new String[] { "comment", "commentdate", "commentposter" };
        int[] to = new int[] { R.id.text_comment, R.id.text_commentdate,
                R.id.text_commentposter };
        List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
        for (int i = 0; i < 5; i++) {
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("comment", "testing 1");
            map.put("commentdate", "testing 2");
            map.put("commentposter", "testing 3");
            fillMaps.add(map);
        }
        SimpleAdapter adapter = new SimpleAdapter(this, fillMaps,
                R.layout.newscommentlist, from, to);
        lv.setAdapter(adapter);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to make this work in Java? public static void change(List<?
I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int
Why do I get compiler errors with this Java code? 1 public List<? extends
Is it slower to iterate through a list in Java like this: for (int
I'm getting this error when I use MarshallingView to marshal my list (java.util.List) of
I heard this today during interview for java developer. I had to list some
I have this ParkingLot.java public class ParkingLot { private final int size; private Car[]
Location.java package com.localisation; import java.io.IOException; import java.util.List; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
I'm rather new to both Java programming and to Android development, so my learning

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.