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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:42:40+00:00 2026-06-15T14:42:40+00:00

I’m having troubles with an development, it’s my first android application with Eclipse JUNO.

  • 0

I’m having troubles with an development, it’s my first android application with Eclipse JUNO.
I want to populate a Listview in a ListActivity with public static variables, assigned correctly (with debugger i check that).
The problem is that the listview is showing me the correct numbers of rows, but with blank data.

He is my code:

Grilla.java

import android.os.Bundle;
import android.app.ListActivity;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class Grilla extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try
        {
            SimpleAdapter adapter = new SimpleAdapter(Grilla.this, VariablesPublicas.listado_grilla, R.layout.mylistrow,
                    VariablesPublicas.ColumnTags, new int[] {R.id.column1, R.id.column2});
            setListAdapter(adapter);

            //getListView().setTextFilterEnabled(true);
        }
        catch(Exception e) {
            System.out.println(e.toString());
        }
    }

     protected void onListItemClick(ListView l, View v, int position, long id) {
            super.onListItemClick(l, v, position, id);
            Object o = l.getItemAtPosition(position);
            VariablesPublicas.itemSeleccionado = o.toString();
            finish();

    }

}

mylistrow.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">

    <TextView
        android:id="@+id/column1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:visibility="invisible" />

    <TextView
        android:id="@+id/column2"
        android:layout_width="fill_parent"
        android:layout_height="34dp"
        android:text="2" />

</LinearLayout>

activity_grilla.xml (Grilla.java)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ListView
        android:id="@+id/listView_grilla"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        tools:listitem="@layout/mylistrow" >

    </ListView>

</LinearLayout>

Main application:

public class Main extends Activity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final Button btn_buscarobra = (Button) findViewById(R.id.btn_buscarobra);

        btn_buscarobra.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
                servicioweb WS = new servicioweb();
                try {
                    String obras = WS.ObtenerObras("");
                    org.w3c.dom.Document doc = WS.XMLfromString(obras);

                    NodeList nodes = doc.getElementsByTagName("entry");

                    //fill in the list items from the XML document
                    VariablesPublicas.listado_grilla = new ArrayList<HashMap<String, String>>();

                    for (int i = 0; i < nodes.getLength(); i++) {
                        Element e = (Element)nodes.item(i);
                        HashMap<String, String> map = new HashMap<String, String>();
                        map.put("id_obra", servicioweb.getValue(e, "IdObra"));
                        map.put("obra", servicioweb.getValue(e, "Obra"));
                        //VariablesPublicas.listado_grilla.(new String[] {servicioweb.getValue(e, "IdObra"), 
                        //      }); 
                        VariablesPublicas.listado_grilla.add(map);

                    }   
                    VariablesPublicas.ColumnTags = new String[] {"#", "OBRA"};
                    Intent listaObras = new Intent(Main.this, Grilla.class);
                    startActivityForResult(listaObras,0);

                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });   
    }

When i click an item in listview it return the correct value.

Thanks!

Gonzalo.

  • 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-15T14:42:41+00:00Added an answer on June 15, 2026 at 2:42 pm

    You have a key mismatch.

    The keys in VariablesPublicas.ColumnTags should correspond to the ones in your maps.

    Use either:

    map.put("id_obra", servicioweb.getValue(e, "IdObra"));
    map.put("obra", servicioweb.getValue(e, "Obra"));
    ...
    VariablesPublicas.ColumnTags = new String[] {"id_obra", "obra"};
    

    or:

    map.put("#", servicioweb.getValue(e, "IdObra"));
    map.put("OBRA", servicioweb.getValue(e, "Obra"));
    ...
    VariablesPublicas.ColumnTags = new String[] {"#", "OBRA"};
    
    • 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
We're building an app, our first using Rails 3, and we're having to build
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.