这是代码。每当我点击Gridview中的任何一个项目时,我想打开一个新活动。请帮忙。我知道我们将使用切换案例,但无法弄清楚如何。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//set grid view item
Bitmap homeIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.home);
Bitmap userIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.personal);
gridArray.add(new Item(homeIcon,"Home"));
gridArray.add(new Item(userIcon,"User"));
gridArray.add(new Item(homeIcon,"House"));
gridArray.add(new Item(userIcon,"Friend"));
gridArray.add(new Item(homeIcon,"Home"));
gridArray.add(new Item(userIcon,"Personal"));
gridArray.add(new Item(homeIcon,"Home"));
gridArray.add(new Item(userIcon,"User"));
gridArray.add(new Item(homeIcon,"Building"));
gridArray.add(new Item(userIcon,"User"));
gridArray.add(new Item(homeIcon,"Home"));
gridArray.add(new Item(userIcon,"xyz"));
gridView = (GridView) findViewById(R.id.gridView1);
customGridAdapter = new CustomGridViewAdapter(this, R.layout.row_grid, gridArray);
gridView.setAdapter(customGridAdapter);
}
}
答案 0 :(得分:1)
定义意图
confHadoop.addResource(Paths.get("/opt/hadoop-2.7.3/etc/hadoop/core-site.xml"));
然后为GridView定义项目单击侦听器。
Intent intent;