Sorry if I'm asking something trivial but I can't figure it out for
the life of me. Essentially what I want to have is a simple table like
GUI and I figured GridView is what I need. I wrote a simple GridView
test app that sets 3 columns and should have few rows of data. Here is
my test data
                private Row[] mData = {
                                new Row("Row1", "Data1", 1999),
                                new Row("Row2", "Data2", 2000),
                                new Row("Row3", "Data3", 2001),
                };
And this is pretty much how I want this data to be displayed in the
grid - 3 rows of 3 cells that hold my data. What I can't figure out
how to do is create views and set values inside individual cells in
each row.

Here is my code that should populate GridView
public class GridDataAdapter extends BaseAdapter {
                public GridDataAdapter(Context c) {
                    mContext = c;
                }

                public int getCount() {
                    return mData.length;
                }

                public View getView(int position, View convertView,
ViewGroup parent) {
                    TextView textView;
                    if (convertView == null) {
                        textView = new TextView(mContext);
                        textView.setLayoutParams(new GridView.LayoutParams(45,
45));
                    } else {
                        textView = (TextView) convertView;
                    }

                    textView.setText(mData.data1);??? based on
position??? what is position???

                    return textView;
                }


Here is the problem - How do I set values of individual cells in each
row?
I know I can create a linear layout with 3 TextViews in my view but
then I would just be turning gridview into a listview. What should
getCount return? Number of rows or total number of cells
(rows*columns)?
I'm sure I'm missing something obvious here. Please help :)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to