0

I can't use listview because this layout will already requires scrolling. So this leaves me at a problem: how to create my tables.

What I know:

  • The size of the JSON array

I was going to try to make every cell in XML and do a for loop in the code, but my predicament is that I can't findViewById very well, because the R.id.myId names are difficult to account for, and are integers instead of strings. (probably a problem not as large as I am making it).

So here, I know the server call will return a json array with up to 5 objects in it. How can I populate my view?

I am using a LinearLayout for each row, much like I would be preparing a custom list view in preparation.

Insight appreciated.

1 Answer 1

2

Is there a specific reason you need it to be a ListView? If not you could try a LinearLayout with a vertical orientation as the container for your list. Just put the container in your xml and you can programatically add the rows that you generate using addView().

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

4 Comments

oh, it isn't going to be a listview because of the scrolling within scrollview problem. So I'll consider your other suggestion
Use table layout we can dynamically addviews to it
Yes, a TableLayout would work too. If you decide to go with that, remember that each of the rows would need to be wrapped in a TableRow, and that the spacing of your columns will depend on how many children each of your LinearLayout rows has.
I am new to doing tablelayouts programmatically, can you help me here stackoverflow.com/questions/10622880/…

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.