linux 浏览器源码下载,Android开发:图片浏览器源码
Android 圖片瀏覽器源碼,是你學習Android很好的例子,希望對你的學習有幫助。
main.xml
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@drawable/grid_background"
/>
Android開發:圖片瀏覽器源碼下載地址:
用戶名與密碼都是www.linuxidc.com
具體下載目錄在 /pub/Android源碼集錦/2011年/9月/Android開發:圖片瀏覽器源碼/
示例:
package com.xmobileapp.pictureviewer;
import java.io.File;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
class PictureShowUtils {
// 圖片存儲位置,SD卡的pic目錄下。
private String dirName = Environment.getExternalStorageDirectory().toString() + "/pic/";
// 用于記錄目錄下圖片名稱的字符串數組
String[] filenames = null;
// 在構造函數中初始化filenames
PictureShowUtils () {
try{
filenames = new File(dirName).list();
}
catch(Exception e){
filenames = null;
}
}
// 獲取圖片數量
public int getCount () {
if(filenames == null)
return 0;
return filenames.length;
}
// 獲取指定索引的圖片
public Bitmap getImageAt (int i) {
String path = dirName;
if(i>=filenames.length)
return null;
path += filenames[i];
// 使用BitmapFactory.decodeFile讀取圖片內容
Bitmap b = BitmapFactory.decodeFile(path);
return b;
}
}
總結
以上是生活随笔為你收集整理的linux 浏览器源码下载,Android开发:图片浏览器源码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 摩尔庄园买的小鸡在哪?
- 下一篇: 装电视机顶盒每月收费多少