android gallery的使用
来源:互联网 发布:java 宏命令 编辑:程序博客网 时间:2024/05/16 09:33
1:
xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Gallery
android:id="@+id/imagegallery"
android:layout_width="fill_parent"
android:layout_height="match_parent" />
</LinearLayout>
2:
java文件
package com.example.cloud.hdplayer2.faq;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
public class ImageShowActivity extends Activity {
private Gallery imagegallery;
private ImageView image;
private String pos;
private ImageAdapter imageadapter;
private int[] images = new int[] { R.drawable.m1, R.drawable.m2,
R.drawable.m3, R.drawable.m1, R.drawable.m1, R.drawable.m1,
R.drawable.m1 };
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_imageshow);
imagegallery = (Gallery) findViewById(R.id.imagegallery);
imageadapter = new ImageAdapter(getApplicationContext());
initview();
}
private void initview() {
imagegallery.setAdapter(imageadapter);
imagegallery.setSelection(0);
}
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context context) {
mContext = context;
}
public int getCount() {
return images.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView image = new ImageView(mContext);
image.setImageResource(images[position]);
image.setAdjustViewBounds(true);
image.setLayoutParams(new Gallery.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
return image;
}
}
}
- android gallery的使用
- android 这 Gallery的使用
- Android组件的使用:Gallery
- Android中的Gallery的使用
- Android中的Gallery的使用
- Android中的Gallery的使用
- Android中的Gallery的使用
- Android中Gallery的使用
- Android之Gallery的使用
- android 的 Gallery 的简单使用
- android Gallery与ImageView的结合使用
- android gallery控件的使用问题
- Android中Gallery和ImageSwitcher的使用
- Android中Gallery和ImageSwitcher的使用
- android 画廊控件Gallery的使用
- Android : Gallery使用例子
- android Gallery的学习心得
- android--Gallery的实现
- Android Process bar的自定义进度条 使用9 patch导致直接无法显示进度的问题
- hibernate对象的三种状态
- MySQL 多主一从备份 .
- JVM 发生native heap溢出问题
- Eclipse 如何重新编译程序
- android gallery的使用
- Python, 自学小白要摸索它的String ...
- @value的2种注入方法
- 一张图说明CDN网络的原理
- oracle 11g Snapshot Standby数据库
- spring错误
- MYSQL中delete删除多表数据 .
- 理解linux虚拟文件系统VFS - 概述
- poj 1042 Gone Fishing