Gallery 的 Demo(6)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:34 点击:次
android:layout_height="fill_parent" android:padding="10px"
android:verticalSpacing="10px" android:horizontalSpacing="10px"
android:numColumns="auto_fit" android:columnWidth="60px"
android:stretchMode="columnWidth" android:gravity="center">
</GridView>
_GridView.java
代码
package com.webabcd.view;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class _GridView extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.gridview);
setTitle("GridView");
GridView gridView = (GridView) findViewById(R.id.gridView);
// 指定网格控件的适配器为自定义的图片适配器
gridView.setAdapter(new ImageAdapter(this));
}
// 自定义的图片适配器
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context context) {
mContext = context;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>