0

I've been trolling for some time now trying to find a way to implement this but have come up dry. Let me state that I am fairly new to java/android development so please be gentle.

What I have is a multidimensional array giving info about a store location like so

static final String[][] coordinates = new String[][] {
    {"1","location_name", "managername","geo:geolocation?z=10" },
    {"2","location_name","managername","geo:geolocation?z=10" },
    {"3","location_name","managername","geo:geolocation?z=10" },
    {"4","location_name","managername","geo:geolocation?z=10" }

};

What I am trying to do is just pull the LOCATION_NAME and MANAGERNAME from the array per row, and display it in a list view using the layout xml described here, http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html.

I was reading that it might be best to use the matrix cursor to implement this, but as being new to java development, i'm a bit confused as to how I'd go about doing this.

Anyone have any ideas that can guide me in the right direction?

Thanks, Ryan

EDIT: I should note, I decided to change to a simpler method of implemenation... as least for now. NOW, I am using just two single dimension arrays, one for LOCATION_NAME and one for MANAGER_NAME. I am using the 2 row layout described in the link. Where I am running into a snag is in the IconicAdapter. How to I fill both (inner) rows of each row with a separate string? This is what I have, which i know is wrong.

class IconicAdapter extends ArrayAdapter<String>{
   IconicAdapter(){
       super(about.this, R.layout.about_layout, R.id.title, locations);
       super(about.this, R.layout.about_layout, R.id.secondLine, managers);
   }
0

1 Answer 1

2

You will need to subclass ArrayAdapter and override getView(). Here is a free excerpt from one of my books that covers how this is done.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you Commonsware. Any other ideas regarding my edited request? Is there a way I can inflate the rows similar to what I have above?
@dubchamp: "I decided to change to a simpler method of implemenation" -- no, you chose a more complex approach. "Is there a way I can inflate the rows similar to what I have above?" -- no.
i kept the first line inflated in the Iconic adapter class. Then I changed the getView to below, and I can load the second line no problamo with the second array @Override public View getView(int position, View convertView, ViewGroup parent){ View row=super.getView(position, convertView, parent); ImageView icon=(ImageView)row.findViewById(R.id.icon); icon.setImageResource(R.drawable.icon); TextView tv2 = (TextView) row.findViewById(R.id.secondLine); tv2.setText("Manager: " + managers[position]); return(row); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.