How GridLayout items come from the Adapter(List/Image) in Android App

青春壹個敷衍的年華 提交于 2019-11-29 05:07:42

Gridlayout doesn't have any Adapters as its not derived from AbsListView . Only GridView comes with Adapters.

Yes, it is possible. You don;t say what you are using to create the GridView. Following is an example of getting the data from a cursor when you click on a cell of the grid (and putting it into an intent to call another activity):

    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);
        }
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!