android gallery 画廊控件示例
来源:互联网 发布:联通大数据有限公司 编辑:程序博客网 时间:2024/05/28 23:10
gallery.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="这是一个Gallery画廊控件的案例"/> <Gallery android:id="@+id/mygallery" android:layout_width="fill_parent" android:layout_height="fill_parent"/></LinearLayout>
GalleryActivity.java:
package com.example.baseexample;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.Gallery;import android.widget.ImageView;public class GalleryActivity extends Activity {private Gallery mGallery;public void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.gallery);mGallery = (Gallery)findViewById(R.id.mygallery);mGallery.setAdapter(new ImageAdapter(this));}private class ImageAdapter extends BaseAdapter{private Context mContext;private Integer[] mImage = {R.drawable.a,R.drawable.b,R.drawable.c,R.drawable.d,R.drawable.e,R.drawable.f};public ImageAdapter(Context c){mContext = c;}public int getCount(){return mImage.length;}public Object getItem(int position){return position;}public long getItemId(int position){return position;}public View getView(int position,View converView,ViewGroup parent){ImageView i = new ImageView(mContext);i.setImageResource(mImage[position]);i.setScaleType(ImageView.ScaleType.FIT_XY);i.setLayoutParams(new Gallery.LayoutParams(600, 1000));return i;}}}
0 0
- android gallery 画廊控件示例
- Android控件之Gallery(画廊)
- Android基础--Gallery画廊控件
- Android UI控件详解-Gallery(画廊)
- Android 控件之十二:Gallery画廊
- Android Gallery画廊 图片展示控件
- android 画廊控件Gallery的使用
- gallery画廊控件
- 【Android 开发】:UI控件之 Gallery 画廊控件的使用
- android 画廊 gallery
- Android--Gallery,画廊
- Android---画廊(Gallery)
- Android gallery画廊
- Android中的画廊(Gallery)
- Android Gallery画廊
- Android UI控件系列:Gallery(画廊视图)
- 画廊控件Gallery的使用
- android gallery实例(画廊效果)
- 改变学习的三个模式--3月主题总结
- AMD宣布支持DirectX 12 为游戏开发者带来更多福利
- sortedArrayUsingSelector:@selector
- 虚拟机中的mac怎么安装vmare tools
- winform下word文件转.mht
- android gallery 画廊控件示例
- [LeetCode]Same Tree
- 然后相濡以沫
- 运营棋牌游戏平台需注意什么
- 论数字化视频监控的应用
- OpenLayers源码学习(一) 取图算法
- Description Resource Path Location Type Java compiler level does not match the version of the instal
- 误删文件后如何恢复
- I2C设备驱动流程