日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

android stackview,Android StackView 使用示例

發(fā)布時間:2024/7/5 Android 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android stackview,Android StackView 使用示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

cell.xml 布局文件:

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/cellImage"

android:layout_width="200dp"

android:layout_height="200dp"

/>

主布局文件:

android:id="@+id/activity_main"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal"

android:background="@color/colorGray"

>

android:id="@+id/stackView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:loopViews="true"

/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="prev"

android:text="@string/prev"

/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="next"

android:text="@string/next"

/>

主程序代碼:

package com.toby.personal.testlistview;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.SimpleAdapter;

import android.widget.StackView;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

public class MainActivity extends Activity {

final private static String TAG = "Toby_Test";

private StackView stackView = null;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

final int[] images = 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, R.drawable.img11, R.drawable.img12,

R.drawable.dog_001, R.drawable.dog_002, R.drawable.dog_003, R.drawable.dog_004,

R.drawable.dog_005,

R.drawable.girl01, R.drawable.girl02, R.drawable.girl03, R.drawable.girl04,

R.drawable.girl05

};

List> listItems = new ArrayList<>();

for (int i = 0; i < images.length; ++i) {

Map listItem = new HashMap<>();

listItem.put("image", images[i]);

listItems.add(listItem);

}

SimpleAdapter simpleAdapter = new SimpleAdapter(this, listItems, R.layout.cell,

new String[] {"image"}, new int[] {R.id.cellImage});

stackView = (StackView) findViewById(R.id.stackView);

stackView.setAdapter(simpleAdapter);

}

public void prev(View view) {

stackView.showPrevious();

}

public void next(View view) {

stackView.showNext();

}

}

運行效果:

運行效果

參考文獻(xiàn):《瘋狂Android講義(第2版)》

總結(jié)

以上是生活随笔為你收集整理的android stackview,Android StackView 使用示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。