All images are listed under the directory

2010-12-07  来源:本站原创  分类:Mobile  人气:80 

public class GalleryTestActivity extends Activity {
  File photos[];
  private static String TAG = "GalleryTest";
     public void onCreate(Bundle savedInstanceState) {
         File f = new File("/sdcard/pics1");
         photos = f.listFiles(new FilenameFilter() {
    public boolean accept(File dir, String filename) {
     return filename.endsWith("jpg");
         String fileList = "";
         for (File aFile : photos) {
          fileList += aFile.getName() + "\n";
         TextView v = (TextView)findViewById(;

         Gallery gallery = (Gallery)findViewById(;
         gallery.setAdapter(new AddImgAdp(this));

     public class AddImgAdp extends BaseAdapter {
         int GalItemBg;
         private Context cont;

         public AddImgAdp(Context c) {
             cont = c;
             TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
             GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);

         public int getCount() {
             return photos.length;

         public Object getItem(int position) {
             return position;

         public long getItemId(int position) {
             return position;

         public View getView(int position, View convertView, ViewGroup parent) {
          ImageView imgView;
          if (convertView == null)
           imgView = new ImageView(cont);
           imgView = (ImageView)convertView;
String filename = photos[position].getAbsolutePath();
Log.i(TAG, "Loading File " + filename);
             Bitmap bMap = BitmapFactory.decodeFile(filename);

             imgView.setLayoutParams(new Gallery.LayoutParams(120, 90));

             return imgView;
  • Listed in the directory that contains a file 2010-10-07

    FileFilter filterForImageFolders = new FileFilter() { public boolean accept(File folder) { try { //Checking only directories, since we are checking for files within //a directory if(folder.isDirectory()) { File[] listOfFiles = folder.listFiles(); if

  • All images are listed under the directory 2010-12-07

    public class GalleryTestActivity extends Activity { File photos[]; private static String TAG = "GalleryTest"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); File f =

  • Read each of the major Linux mount point directory 2010-03-12

    First, the need has been installed on the system disk has an overall understanding of: [Root @ localhoddddd ~] # fdisk-l Disk / dev / sda: 146.8 GB, 146815733760 bytes 255 heads, 63 sectors / track, 17849 cylinders Units = cylinders of 16065 * 512 =

  • File directory manipulation functions Overview 2010-03-10

    In Python,, Python recursive file operations mainly from the os module, the main methods are as follows: os.listdir (dirname): dirname listed in the directory and files under os.getcwd (): get the current working directory os.curdir: Returns the curr

  • Du Command Function: Statistical directory (or file) the size of disk space occupied 2010-04-11

    du Contents [hide] 1.linux command 2. data unit 3. ozone concentration units [Edit this paragraph] 1.linux command Du Command Functions: Statistical directory (or file) the size of disk space occupied. Syntax: du [-abcDhHklmsSx] [-L] [-X] [- block-si

  • tomcat application directory for a hit put the corresponding file directory to list all 2010-08-14

    56. Are trying to do this function, which in the address bar enter http://localhost:8080/drp1.7/msger enter this directory put the files inside this directory are listed. msger a directory under the corresponding project You have not done such a hit

  • Linux file and directory manipulation commands 2010-12-11

    Quote 1, cat command: used to scroll the screen contents of the file, type the same command under DOS. cat can also look at the contents of multiple files can also be used to merge files General format: cat [- options] fileName [fileName2] ... The ma

  • android directory file for the specified path 2010-12-22

    From package com.Aina.Android; import; import java.util.ArrayList; import java.util.List; import; import; import android.content.DialogInterface; import andr

  • Batch Framework 2010-03-29

    Java Batch Job Framework - # TERASOLUNA Batch FAQ Enterprise Batch Server CA 7 ® Workload Automation Reference Batch Appl

  • java calling c (c + +) to write the dll files and steps for implementation (transfer) 2010-03-29

    JNI using the skills bit by bit in this 32-bit Windows platform, Java native methods to achieve provides a useful example of the steps and guidelines. The examples in this article was created using Sun Microsystems's Java Development Kit (JDK) versio

  • [Change] UltraEdit Tips Notes 2010-02-06

    UltraEdit is used daily in one of the tools. But think about it, the actual use of the function to the power of this tool is only a very small part. Flexible use of this tool can sometimes play a multiplier effect. Record and collect some tips to hel

  • Transfer: os.path things to note 2010-03-05

    Python's standard library includes general operating system os module functions. If you want your program to work with platform-independent, then this module is particularly important. That it allows a program to be written without any changes, they

  • Linux sketchy related to the lower reservoir and the dynamic library search path priority 2010-03-13

    (This article is aimed at dynamic link library, the content source network, re-order of, highlighted some key concerns, please) 1. <br /> Basic knowledge of the whole, the library can be used in three forms: static, shared and dynamic. Static librar

  • Common Unix platform command the resources and performance skills 2010-03-03

    Description This section describes some of the view system information and monitoring system resources and performance tools, performance monitoring tools on the current system has a basic understanding of, and according to the information collected

  • [Change] Simple Unix system command 2010-03-09

    Trackback URI: Because of the IPHONE to perform certain operations, the need to use PUTTY, it must use these instructions. Release more simple so that we learn! cp command of the command's function is

  • Linux Find Command Mastery 2010-04-09

    Linux Find Command Mastery Of: Sheryl Calish A brief introduction of this ubiquitous command of the powerful aspects as well as confusion. Released in July 2008 Linux find command is the Linux command all the most useful one, but also the most chaoti

  • jacob word to html record. txt 2010-04-28

    jacob word to html record. txt 0. Go download 1. I used myeclipse, build a new java project 2. Copy the downloaded file to the lib directory below jacob.jar 3. Create a new class, add t

  • Linux common commands Xiangjie 2010-06-01

    This article comes from: Linux tutorials - If not understand, Welcome to the Linux community to discuss the reason by the majority of computer enthusiasts favorite, for two main reasons, first of all it is free softw

  • The optimal allocation of Tomcat 2010-06-01

    Keywords: tomcat optimization collected from: Here are some optimal allocation will be used for Tomcat main parameters and configuration methods: 1. Tomcat's port number will be changed to 8080. <Connector classN

  • Teach you to customize the [Run ...] quick order 2010-06-23

    I do not know when to play, gradually accustomed to using the Win + R key to run ...] [exhaled dialog box, then type cmd, can open a Windows command line; enter notepad, be able to open Notepad. Today whim, if this feature can be extended to non-Wind