I want to create gridview in android which uses database but I am getting " The constructor ArrayAdapter(Startup, int, ArrayList) is undefined" error on "Arrayadapter adapter=new Arrayadapter.." line ....my code is as given below...please help me to solve it out.....thanks in advance
Startup.java activity file
public class Startup extends Activity {
private GridView gridView;
final static ArrayList<Contact> timetable = new ArrayList<Contact>();
String response;
WebAPIRequest web = new WebAPIRequest();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
setContentView(R.layout.main);
String url = "http://192.168.0.101/attendance/webservice/gettingTodaysLectures.php";
new setd().execute(url);
}
public void displayTimeTable(String response) {
String getAllData[] = response.split("<br>");
Contact displaylec;
for (int i = 0; i < getAllData.length - 1; i++) {
String tempdata[] = getAllData[i].split(":");
// tmepdata[0]=start time // tempdata[1]=end time //
// tempdata[2]=semester
// tempdata[3]=department // tempdata[4]=division //
// tempdata[5]=subject
// tempdata[6]=type // tempdata[7]=batch // tempdata[8]=classno
displaylec = new Contact(tempdata[0], tempdata[1], tempdata[2],
tempdata[3], tempdata[4], tempdata[5], tempdata[6],
tempdata[7], tempdata[8]);
timetable.add(displaylec);
Log.i("All sem id", tempdata[0] + ":" + tempdata[1] + ":"
+ tempdata[2] + ":" + tempdata[3] + ":" + tempdata[4] + ":"
+ tempdata[5] + ":" + tempdata[6] + ":" + tempdata[7] + ":"
+ tempdata[8]);
Toast.makeText(getApplicationContext(), tempdata[0], 1);
}
gridView = (GridView) findViewById(R.id.gridView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, timetable);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(getApplicationContext(),
((TextView) v).getText(), Toast.LENGTH_SHORT).show();
}
});
}
public class setd extends AsyncTask<String, Void, Void> {
ProgressDialog pd;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
// pd=new ProgressDialog(getApplicationContext());
// pd.setTitle("Loading .....");
// pd.setMessage("Inserting data");
Log.i("ddd", "dd");
pd = ProgressDialog.show(Startup.this, "Loading .....",
"getting data");
}
@Override
protected Void doInBackground(String... params) {
// TODO Auto-generated method stub
response = web.performGet(params[0]);
Log.i("response", response);
Log.i("response Display Extraactivity", response);
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
pd.cancel();
// Main Logic Write here
Log.i("RESPONSE : ", response.toString());
displayTimeTable(response.toString());
}
}