是否可以在Android中从适配器获取 GridLayout 项目。
类似,GridView中的项来自与此视图关联的ListAdapter。
请澄清我的疑问..谢谢
答案 0 :(得分:6)
Gridlayout没有任何Adapters,因为它不是从AbsListView派生的。只有GridView附带适配器。
答案 1 :(得分:-2)
是的,有可能。你不要说你用来创建GridView的东西。以下是单击网格单元格并将其置于意图调用其他活动时从光标获取数据的示例:
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);
}
});