Hi I have 49 edittexts in my app for which I used gridview. So, I created an activity whose onCreate() method contains the adapter object. In the custom adapter class I gave count=49. So, 49 edittexts are arranged in the gridview.
But my problem is I want to set some values in the edittexts by default as soon as my activity is visible.(hint attribute doesn't not work in my app, as my default values in the edittexts are generated randomly ). So, after a lot of thinking I retrieved the edittexts' objects by using the following code snippet in my activity class and kept this code in one method.
int k=0;
for(int i=0;i<editText.length;i++)
{
for(int j=0;j<editText.length;j++)
{
editText[i][j]=(EditText)gridView.getChildAt(k);
k++;
}
}
But this method should be called before the activity is visible. At the very first time I kept this snippet in the onCreate() method after the statement gridView.setAdapter(new TextAdapter(this));
. But no use, the application is showing force close. Later I kept this in onStart(), but no use again, the edittext objects are still unavailable and showing force close. So, to test this, I kept in one method which gets executed when the button is clicked in the activity, then the edittexts objects are available. So, I don't want to set the values after the manual operation(here button click). I want the values to be set automatically before the activity becomes visible. Still any call back methods which solve my problem? I have been searching many sources for this problem and kinda exhausted. Please suggest. Code snippet would be appreciated.