定义一个左右滑动的图片,文件图片是写死的 MainActivity
package com.lenovo.halo.gallery; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; //import android.os.LauncherSyncManager; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.ImageView; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class MainActivity extends Activity { private static final String TAG = "MyLauncher"; private MyHandler m_h; private ImageView i; private int[] ids = { R.drawable.p12, R.drawable.p13, R.drawable.p1, R.drawable.p2, R.drawable.p3, R.drawable.p4, R.drawable.p5, R.drawable.p6, R.drawable.p7, R.drawable.p8, R.drawable.p9, R.drawable.p10, R.drawable.p11 // //no5test add img here!!!!!!! }; int current = 0; @Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); i = (ImageView) findViewById(R.id.image); i.setImageResource(ids[current]); PowerManager a = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLock w = a.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG); w.acquire(); i.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { // TODO Auto-generated method stub current++; if (current == ids.length) { current = 0; } m_h.removeMessages(1); Message message1 = new Message(); message1.what = 1; m_h.sendMessage(message1); return false; } }); m_h = new MyHandler(); } class MyHandler extends Handler { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case 1: i.setImageResource(ids[current]); Log.e(TAG, "current img is" + ids[current] + "id is " + current); break; } } } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { Log.e(TAG, "current img is" + ids[current] + "id is " + current + "event is" + event.getAction()); if (event.getAction() == KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: current++; if (current == ids.length) { current = 0; } i.setImageResource(ids[current]); default: break; } } return super.onKeyDown(keyCode, event); } @Override protected void onPause() { Log.i(TAG, "onPause"); this.finish(); System.exit(0); super.onPause(); } }
定义XML文件
<RelativeLayout 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" tools:context="com.lenovo.halo.gallery.MainActivity" > <ImageView android:id="@+id/image" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="fitXY" /> <ImageView android:id="@+id/up_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:src="@drawable/up"/> <ImageView android:id="@+id/down_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:src="@drawable/down" /> </RelativeLayout>
以上为直接读取drawable里边的文件图片写死的
相关推荐
Android应用源码之Gallery2_Android
Gallery2.apk 这是一个相机应用
android4.2相册 Gallery2应用程序源码,谷歌官方的源码,对相册 Gallery2感兴趣的可以下载下来仔细研究和修改
Gallery2源码流程说明,该Gallery2源码说明是基于高通平台。把Gallery2涉及的一些流程及知识点作了一些整理,有些也参考网上朋友的说明与介绍。希望对修改Gallery2的朋友提供一个思路。
首页幻灯显示图文的插件content-gallery使用方法,直接复制插件目录content-gallery到WP插件目录里面。然后到WP后台插件里面启用Featured Content Gallery即可。 2.Featured Content Gallery显示图片的方法:首先,...
1.gallery循环 2.java反射机制获取图片 3.可以从gallery中删除图片 初学必看。。
Android源码开发之Android Gallery2代码分享
Android4.4图库Gallery2源码,变化很大,不可独立运行
这个demo实现了类似iOS上面的CoverFlow功能。 主要有两个功能 1, 实现图片的倒影效果 2,重写gallery的一些方法实现Y轴上的旋转,Z轴上的缩放。
android 4.0 完整的原生gallery2代码 包括所有的代码 资源。
Gallery画廊控件用法实例源代码,包含2D及3D两种用法
安卓Android源码——Gallery2.rar
FlashDen Photo Inertia Gallery V2
Page Flip Image Gallery插件使用: 1>激活插件后,我们接下来就是创建Flippingbook了,单击“FlippingBook”--->”Images“进行新建Gallery,点击"Create New Geallery"按钮,为Gallery命名(用英文命名),新建...
2.在博客上为Lazyest Gallery创建一个页面/文章,然后把代码[lg_gallery]放入到页面或文章就OK了。 3.下载Lazyest Gallery插件,将压缩包解压后,把文件夹上传到wp-content/plugins/目录下,登录WordPress管理后台,...
gallery pages.pdf
UI开发第七篇之Android gallery实现图片的循环旋转UI开发第七篇之Android gallery实现图片的循环旋转
主要为大家解决如何将开源Gallery2图库整合到Joomla这一问题。
android gallery3d效果的简单实现 有遮盖 http://blog.csdn.net/kiritor/article/details/8701025
详情请参阅 在Eclipse中编译运行Android4.3应用源码——Launcher2和Gallery2 http://blog.csdn.net/klpchan/article/details/11843295