How GridLayout elements come from the adapter (list / image) in an Android app

Is it possible to get GridLayout elements from an adapter on Android.

Like, the elements in the GridView come from the list associated with this view.

Please clarify my doubt .. Thank you

+4
source share
2 answers

There are no adapters in Gridlayout because it is not derived from AbsListView. Only GridView comes with adapters.

+6
source

Yes it is possible. You do not say that you use to create a GridView. The following is an example of obtaining data by the cursor when you click on a grid cell (and including it in the intent to trigger another action):

gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Cursor c = (Cursor) (parent.getAdapter().getItem(position)); Intent i = new Intent(mCtx, ScheduleEdit.class); i.putExtra("RowId", position); i.putExtra("Machine", c.getString(c .getColumnIndex(ScheduleDBAdapter.SCHEDULE_MACHINE))); i.putExtra("Priority", c.getString(c .getColumnIndex(ScheduleDBAdapter.SCHEDULE_PRIORITY))); i.putExtra("RunJob", c.getString(c .getColumnIndex(ScheduleDBAdapter.SCHEDULE_RUNJOB))); i.putExtra("Operator", c.getString(c .getColumnIndex(ScheduleDBAdapter.SCHEDULE_OPERATOR))); i.putExtra("NxtJob1", c.getString(c .getColumnIndex(ScheduleDBAdapter.SCHEDULE_NXTJOB1))); i.putExtra("NxtJob2", c.getString(c .getColumnIndex(ScheduleDBAdapter.SCHEDULE_NXTJOB2))); startActivityForResult(i, ACTIVITY_EDIT); } }); 
-2
source

All Articles