FileDocCategorySizeDatePackage
A3DSelector.javaAPI DocAndroid 5.1 API3417Thu Mar 12 22:22:44 GMT 2015com.android.modelviewer

A3DSelector

public class A3DSelector extends android.app.ListActivity
A list view where the last item the user clicked is placed in the "activated" state, causing its background to highlight.

Fields Summary
File[]
mCurrentSubList
File
mCurrentFile
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);

        populateList(new File("/sdcard/"));
    
protected voidonListItemClick(android.widget.ListView l, android.view.View v, int position, long id)

        if (position == 0) {
            File parent = mCurrentFile.getParentFile();
            if (parent == null) {
                return;
            }
            populateList(parent);
            return;
        }

        // the first thing in list is parent directory
        File selectedFile = mCurrentSubList[position - 1];
        if (selectedFile.isDirectory()) {
            populateList(selectedFile);
            return;
        }

        Intent resultIntent = new Intent();
        resultIntent.setData(Uri.fromFile(selectedFile));
        setResult(RESULT_OK, resultIntent);
        finish();
    
private voidpopulateList(java.io.File file)


        mCurrentFile = file;
        setTitle(mCurrentFile.getAbsolutePath() + "/*.a3d");
        List<String> names = new ArrayList<String>();
        names.add("..");

        mCurrentSubList = mCurrentFile.listFiles(new A3DFilter());

        if (mCurrentSubList != null) {
            for (int i = 0; i < mCurrentSubList.length; i ++) {
                String fileName = mCurrentSubList[i].getName();
                if (mCurrentSubList[i].isDirectory()) {
                    fileName = "/" + fileName;
                }
                names.add(fileName);
            }
        }

        // Use the built-in layout for showing a list item with a single
        // line of text whose background is changes when activated.
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_activated_1, names));
        getListView().setTextFilterEnabled(true);

        // Tell the list view to show one checked/activated item at a time.
        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);