这是我的代码代码,我没有从 gridview setOnClickListener 得到任何响应。请帮帮我。
setContentView(R.layout.myfav);
gView = (GridView) findViewById(R.id.grid);
PackageManager pm = this.getPackageManager();
context = MyFav.this;
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
gView.setAdapter(new MyAdapter());
// save.setOnClickListener(this);
// cancel.setOnClickListener(this);
gView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Log.e("inside click", "" + arg2);
Toast.makeText(getApplicationContext(), "Hello" + arg2,
Toast.LENGTH_SHORT).show();
}
});
这是我的网格视图
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_centerHorizontal="true"
android:numColumns="3"
android:stretchMode="columnWidth" >
</GridView>