使用ImageSwitcher点击按钮浏览图片
来源:互联网 发布:济南关键词优化外包 编辑:程序博客网 时间:2024/05/12 06:46
<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" android:orientation="vertical" tools:context=".MainActivity" > <LinearLayout android:layout_width="fill_parent" android:layout_height="250dp" android:gravity="center"> <ImageSwitcher android:id="@+id/IS01" android:layout_width="wrap_content" android:layout_height="wrap_content" > </ImageSwitcher> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/pre" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上一张" /> <Button android:id="@+id/next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下一张" /> </LinearLayout></LinearLayout>
package com.example.imageswitcher;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ImageSwitcher;import android.widget.ImageView;import android.widget.ViewSwitcher.ViewFactory;public class MainActivity extends Activity implements ViewFactory, OnClickListener {private final static Integer[] INTEGERS = {R.drawable.a,R.drawable.d,R.drawable.c,R.drawable.d,R.drawable.e,R.drawable.f,R.drawable.g,R.drawable.h,};ImageSwitcher imageSwitcher;Button button,button2;private static int index=0;private final static int DOWN_ID = 0x123456;private final static int UP_ID = 0x123456;private final static int SWICHER_ID = 0x123456;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);imageSwitcher = (ImageSwitcher)findViewById(R.id.IS01);button = (Button)findViewById(R.id.pre);button2 = (Button)findViewById(R.id.next);imageSwitcher.setFactory(this);imageSwitcher.setImageResource(INTEGERS[index]);button.setOnClickListener(this);button2.setOnClickListener(this);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic View makeView() {return new ImageView(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.pre:index--;if(index<0){index = INTEGERS.length-1;}imageSwitcher.setImageResource(INTEGERS[index]);break;case R.id.next:index++;if(index>=INTEGERS.length){index = 0;}imageSwitcher.setImageResource(INTEGERS[index]);break;}}}
0 0
- 使用ImageSwitcher点击按钮浏览图片
- 使用ImageSwitcher实现点击按钮浏览图片功能
- Android ImageSwitcher 图片切换 按钮点击切换
- 使用ImageSwitcher和Gallery实现图片的浏览
- 使用ImageSwitcher和Gallery实现图片的浏览
- ImageSwitcher与gallery图片浏览
- ImageSwitcher实现图片浏览切换功能
- Gallery和imageSwitcher结合使用浏览图片(简单图片浏览器)
- 使用ImageSwitcher切换图片
- 简单图片浏览工具—ImageSwitcher和Gallery组件结合使用
- C# 点击按钮浏览文件夹
- 使用ImageSwitcher实现换图片
- 使用ImageSwitcher实现换图片
- Fileupload控件点击“浏览”按钮,选择图片后需要立即显示所选择的图片
- Eg:Gallery与ImageSwitcher结合的图片浏览小程序
- android 用ImageSwitcher+Gallery实现图片浏览效果
- Android UI, Gallery(过时), ImageSwitcher, 简单图片浏览工具
- 使用ColorBox弹出图片组浏览层,点击换图
- 回发或回调参数无效 的解决办法
- 侧方移位
- 归并排序
- LeetCode: Linked List Cycle II [142]
- 一些开源的消息服务器--来自oschina检索结果
- 使用ImageSwitcher点击按钮浏览图片
- poj3067 Japan(树状数组)
- CATransition Demo
- 针对接口编程
- 艺术联合社(dp)
- 新的一页
- Server_W3wp.exe进程是什么?
- 选项卡实现界面转换
- LeetCode: Reorder List [143]