Android 控件之GridView图片表格控件
1.首先创建工程,在主布局文件中添加一个GridView控件。
2.找足够的图片放在资源文件下。
3.在主Activity中进行相应的操作。代码如下:
package com.example.android_gridview;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends Activity {
private GridView gridView;
private ImageAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gridView = (GridView) this.findViewById(R.id.gridview);
adapter = new ImageAdapter();
gridView.setAdapter(adapte