0

TextView has setText(String), but when looking on the Doc, I don't see one for GridLayout. Is there an adapter or something that I need to use instead? If so, which one? Thanks in advance for any of the help.

Andy
  • 10,553
  • 21
  • 75
  • 125
  • yes, you need an adapter – C. Leung May 25 '12 at 01:49
  • I just added it to clarify I want more than just a single word response lol. – Andy May 25 '12 at 01:51
  • 1
    you can create an adapter which extends `BaseAdapter`, and [here](http://stackoverflow.com/questions/982386/android-simple-gridview-that-displays-text-in-the-grids) is an example. – C. Leung May 25 '12 at 01:55
  • What I was thinking about using was a GridLayout, but the tutorial is GridView. My question is for a calendar layout, which one makes sense? And you might want to put what you told me in an answer. – Andy May 25 '12 at 02:12
  • sorry, my mistake... well then you can't use an adapter for `GridLayout`, since it is a `ViewGroup`, you can only add views to it. I think a `GridView` should do for a calendar. – C. Leung May 25 '12 at 02:26
  • Oh no, thats fine. You definitely gave me a great starting point. I really appreciate it. But I will definitely look into GridView. – Andy May 25 '12 at 02:29
  • There is one thing I am confused about. What exactly is a context – Andy May 25 '12 at 02:31
  • i've got this question when i started programming Android, hope [this](http://stackoverflow.com/questions/3572463/what-is-context-in-android) can help you. as a practice, i usually create a member variable `private Context mContext = this;`, and whenever i need Context, i'll put `mContext` to it. – C. Leung May 25 '12 at 02:45
  • Btw, you should probably put your answer so I can accept it lol. – Andy May 28 '12 at 00:16

1 Answers1

1

GridLayout is a ViewGroup, to which you can only add views; if you want to make a calendar, it would be better to use a GridView.

for the GridView, create an adapter which extends BaseAdapter, and use TextView for the grid's layout. here is an example.

Community
  • 1
  • 1
C. Leung
  • 6,218
  • 3
  • 20
  • 32