Example usage for android.widget AdapterView getChildAt

List of usage examples for android.widget AdapterView getChildAt

Introduction

In this page you can find the example usage for android.widget AdapterView getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:self.philbrown.droidQuery.$.java

/**
 * If the first view of the current selection is a subclass of {@link AdapterView}, this will loop through all the 
 * adapter data and invoke the given function, passing the varargs:
 * <ol>//from  w  ww .  ja  va  2  s .  c  o  m
 * <li>the item from the adapter
 * <li>the index
 * </ol>
 * Otherwise, if the first view in the current selection is a subclass of {@link ViewGroup}, {@code each} will
 * loop through all the child views, and wrap each one in a droidQuery object. The invoked
 * function will receive it, and an int for the index of the selected child view.
 * @param function Function the function to invoke
 * @return this
 */
public $ children(Function function) {
    if (view(0) instanceof AdapterView) {
        AdapterView<?> group = (AdapterView<?>) view(0);
        for (int i = 0; i < (group).getCount(); i++) {
            function.invoke($.this, group.getItemAtPosition(i), i);
        }
    } else if (view(0) instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view(0);
        for (int i = 0; i < group.getChildCount(); i++) {
            function.invoke($.with(group.getChildAt(i)), i);
        }
    }
    return this;
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void setRemoteFilelistItemClickListener() {
    if (remoteFileListView == null)
        return;/*from   w w  w.  j  a  v a 2s .  c  o  m*/
    remoteFileListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
            for (int j = 0; j < parent.getChildCount(); j++)
                parent.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
            if (!isUiEnabled())
                return;
            final FileListItem item = remoteFileListAdapter.getItem(position);
            sendDebugLogMsg(1, "I", "Remote filelist item clicked :" + item.getName());
            if (remoteFileListAdapter.isItemSelected()) {
                item.setChecked(!item.isChecked());
                remoteFileListAdapter.notifyDataSetChanged();
            } else {
                setUiEnabled(false);
                if (item.isDir()) {
                    NotifyEvent ne = new NotifyEvent(mContext);
                    ne.setListener(new NotifyEventListener() {
                        @Override
                        public void positiveResponse(Context c, Object[] o) {
                            String t_dir = item.getPath() + "/" + item.getName();

                            remoteCurrFLI.pos_fv = remoteFileListView.getFirstVisiblePosition();
                            if (remoteFileListView.getChildAt(0) != null)
                                remoteCurrFLI.pos_top = remoteFileListView.getChildAt(0).getTop();
                            remoteDir = t_dir.replace(remoteBase + "/", "");

                            remoteFileListAdapter = (FileListAdapter) o[0];
                            remoteFileListView.setAdapter(remoteFileListAdapter);
                            remoteFileListAdapter.notifyDataSetChanged();
                            for (int j = 0; j < remoteFileListView.getChildCount(); j++)
                                remoteFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
                            setFilelistCurrDir(remoteFileListDirSpinner, remoteBase, remoteDir);
                            setFileListPathName(remoteFileListPathBtn, remoteFileListCache, remoteBase,
                                    remoteDir);
                            setEmptyFolderView();
                            remoteFileListView.setSelection(0);
                            putDirHist(remoteBase, remoteDir, remoteDirHist);

                            FileListCacheItem dhi = new FileListCacheItem();
                            dhi.profile_name = remoteFileListDirSpinner.getSelectedItem().toString();
                            dhi.base = remoteBase;
                            dhi.directory = t_dir;
                            dhi.file_list = remoteFileListAdapter.getDataList();
                            dhi.directory_history.addAll(remoteDirHist);
                            putFileListCache(dhi, remoteFileListCache);
                            remoteCurrFLI = dhi;

                            setUiEnabled(true);

                            remoteFileListTopBtn.setEnabled(true);
                            remoteFileListUpBtn.setEnabled(true);

                        }

                        @Override
                        public void negativeResponse(Context c, Object[] o) {
                            setUiEnabled(true);
                        }
                    });
                    String t_dir = item.getPath() + "/" + item.getName();
                    FileListCacheItem dhi = getFileListCache(t_dir, remoteFileListCache);
                    if (dhi == null) {
                        createRemoteFileList(item.getPath() + "/" + item.getName(), ne);
                    } else {
                        remoteBase = dhi.base;
                        remoteDir = dhi.directory.replace(dhi.base + "/", "");
                        remoteFileListAdapter.setDataList(dhi.file_list);
                        remoteFileListAdapter.notifyDataSetChanged();
                        setFilelistCurrDir(remoteFileListDirSpinner, remoteBase, remoteDir);
                        setFileListPathName(remoteFileListPathBtn, remoteFileListCache, remoteBase, remoteDir);
                        setEmptyFolderView();
                        remoteFileListView.setSelection(0);

                        putDirHist(remoteBase, remoteDir, remoteDirHist);
                        setUiEnabled(true);
                    }
                } else {
                    setUiEnabled(true);
                    if (isFileListItemSelected(remoteFileListAdapter)) {
                        item.setChecked(!item.isChecked());
                        remoteFileListAdapter.notifyDataSetChanged();
                    } else {
                        //                        view.setBackgroundColor(Color.DKGRAY);
                        startRemoteFileViewerIntent(remoteFileListAdapter, item);
                        //commonDlg.showCommonDialog(false,false,"E","","Remote file was not viewd.",null);
                    }
                }
            }
        }
    });
}