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

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

 更新時(shí)間: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實(shí)現(xiàn)在圖片上添加圖層效果

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

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

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

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

    Android事件與手勢(shì)操作詳解

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

    Android BroadcastReceiver接收收到短信的廣播

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

    Android使用SoundPool播放音效

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

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

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

    Android Studio 報(bào)Integer types not allowed錯(cuò)誤

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

    Android中使用SDcard讀取文件

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

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

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

    Android自定義短信驗(yàn)證碼組件

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

最新評(píng)論

郧西县| 商南县| 拜城县| 香港| 田阳县| 夏津县| 揭东县| 建阳市| 梓潼县| 巧家县| 和平区| 资兴市| 阿坝| 临颍县| 水富县| 陵川县| 武山县| 曲水县| 铁力市| 鸡泽县| 修武县| 钦州市| 望都县| 麻城市| 林口县| 英吉沙县| 塔河县| 嫩江县| 外汇| 丹阳市| 交口县| 富源县| 海兴县| 荣昌县| 徐汇区| 偏关县| 东宁县| 泗洪县| 托里县| 黔南| 洞口县|