最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android圖片轉(zhuǎn)換器示例

 更新時間:2014年05月05日 09:13:49   作者:  
這篇文章主要介紹了android圖片轉(zhuǎn)換器示例,需要的朋友可以參考下

MainActivity.java

復(fù)制代碼 代碼如下:

package com.zhang.showPhoto;

import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.ViewSwitcher.ViewFactory;

public class MainActivity extends Activity {

 private int[] imagId=new int[]{
   R.drawable.img01,R.drawable.img02,R.drawable.img03,R.drawable.img04,
   R.drawable.img05,R.drawable.img06,R.drawable.img07,R.drawable.img08,
   R.drawable.img09,R.drawable.img10
  };
 private int index=0;
 private ImageSwitcher imageSwitcher;
 private Button up,down;
 

 @Override
 protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  up=(Button) findViewById(R.id.bt1);
  down=(Button) findViewById(R.id.bt2);

 
  imageSwitcher=(ImageSwitcher) findViewById(R.id.imagSw1);
  imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
  imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
  imageSwitcher.setFactory(new ViewFactory() {

  
   public View makeView() {
    ImageView imageView = new ImageView(MainActivity.this);
    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    imageView.setLayoutParams(new ImageSwitcher.LayoutParams(
      LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT
      ));
    return imageView;
   }
  });

  imageSwitcher.setImageResource(imagId[index]);

  up.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    if(index>0){
     index--;
    }else{
     index=imagId.length-1;
    }
    imageSwitcher.setImageResource(imagId[index]);
   }
  });

  down.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    if(index<imagId.length-1){
     index++;
    }else{
     index=0;
    }
    imageSwitcher.setImageResource(imagId[index]);
   }
  });
 }
}

main.xml

復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/bg1"
    android:id="@+id/llayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="horizontal" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="上一張"
        android:id="@+id/bt1"
        />
    <ImageSwitcher
         android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imagSw1"
        android:layout_gravity="center"
        />
     <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="下一張"
        android:id="@+id/bt2"
        />

</LinearLayout>

相關(guān)文章

  • Android自定義ImageView實現(xiàn)在圖片上添加圖層效果

    Android自定義ImageView實現(xiàn)在圖片上添加圖層效果

    這篇文章給大家主要介紹了利用Android自定義ImageView如何實現(xiàn)在圖片上添加圖層的效果,實現(xiàn)的效果類似在圖片增加秒殺、搶光等標(biāo)簽圖片,對大家開發(fā)的時候具有一定的參考借鑒價值,有需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧。
    2016-11-11
  • Android詳細(xì)講解谷歌推出的官方二維碼掃描庫

    Android詳細(xì)講解谷歌推出的官方二維碼掃描庫

    Google推出的官方二維碼掃描庫你知道嗎?還不知道就落伍咯!本篇文字帶你了解google二維碼掃描庫的詳細(xì)情況與使用,還不知道的朋友快來看看吧
    2022-03-03
  • Android事件與手勢操作詳解

    Android事件與手勢操作詳解

    現(xiàn)在程序都是通過事件實現(xiàn)人機(jī)交互的。事件:用于對圖形界面的操作,有物理按鍵事件和觸摸屏事件兩大類。在Android組件中提供了事件處理的相關(guān)方法,如在View類中提供onTouchEvent()方法重寫觸摸屏事件,setOnTouchListener()方法為組件設(shè)置監(jiān)聽器來處理觸摸屏事件
    2022-12-12
  • Android BroadcastReceiver接收收到短信的廣播

    Android BroadcastReceiver接收收到短信的廣播

    這篇文章主要為大家詳細(xì)介紹了Android BroadcastReceiver接收收到短信的廣播,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android使用SoundPool播放音效

    Android使用SoundPool播放音效

    這篇文章主要為大家詳細(xì)介紹了Android使用SoundPool播放音效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android工具類ImgUtil選擇相機(jī)和系統(tǒng)相冊

    Android工具類ImgUtil選擇相機(jī)和系統(tǒng)相冊

    這篇文章主要為大家詳細(xì)介紹了Android工具類ImgUtil選擇相機(jī)和系統(tǒng)相冊,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-10-10
  • Android Studio 報Integer types not allowed錯誤

    Android Studio 報Integer types not allowed錯誤

    本文給大家分享的是在使用Android Studio的過程中遇到的報Integer types not allowed錯誤的分析及解決方法,非常實用,有需要的小伙伴可以參考下
    2017-10-10
  • Android中使用SDcard讀取文件

    Android中使用SDcard讀取文件

    這篇文章主要介紹了Android中使用SDcard讀取文件的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • Android仿微信底部菜單欄功能顯示未讀消息數(shù)量

    Android仿微信底部菜單欄功能顯示未讀消息數(shù)量

    這篇文章主要介紹了Android仿微信底部菜單欄功能,并顯示未讀消息數(shù)量,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-05-05
  • Android自定義短信驗證碼組件

    Android自定義短信驗證碼組件

    這篇文章主要為大家詳細(xì)介紹了Android自定義短信驗證碼組件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-01-01

最新評論

扎囊县| 全椒县| 长子县| 师宗县| 雷山县| 章丘市| 祁门县| 汶川县| 新巴尔虎左旗| 南皮县| 平罗县| 长岛县| 武邑县| 龙里县| 庄河市| 海阳市| 莫力| 灵璧县| 彭州市| 新源县| 宿州市| 汤阴县| 县级市| 连南| 钟祥市| 兴业县| 当雄县| 通渭县| 濮阳市| 新野县| 潜江市| 梅州市| 科技| 镇原县| 马公市| 新巴尔虎右旗| 松江区| 江西省| 寿宁县| 新巴尔虎右旗| 临颍县|