1

I'm trying to emplement a file explorer with sliding pane interface. But when i scroll the grid view i have my genymotion device display like (http://www.mediafire.com/?kui3x2l7u6ykgx3)

and this is when the app first start (http://www.mediafire.com/?45cg12uk5wadiui)

could any one tell me where shouls i look up or how to fix this?

The images are in the link, sorry for this because i don't have enough reputation to attract image in my post. and here is my code this is the fragment which content the gridview

public class ContentFragment extends Fragment{

public static ArrayList<FileItem> listFileItem = new ArrayList<FileItem>();
public static FileGridAdapter fileGridAdapter = null;
public static int clickTimes = 0;

ArrayList<String> str = new ArrayList<String>();
private Boolean firstLvl = true;
private File path = new File(Environment.getExternalStorageDirectory() + "");

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    loadFiles();
    View rootView = inflater.inflate(R.layout.fragment_content, container, false);
    fileGridAdapter = new FileGridAdapter(getActivity(), android.R.layout.activity_list_item, listFileItem);
    GridView gridView = (GridView) rootView.findViewById(R.id.fileGridView);
    gridView.setAdapter(fileGridAdapter);
    gridView.setOnItemClickListener( new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {

            FileItem fileItem = fileGridAdapter.getItem(arg2);

            if(fileItem.fileIcon == "folder") {
                if(fileItem.fileName == "up") {
                    path = new File(path.toString().substring(0,
                            path.toString().lastIndexOf("/")));
                    if(path.toString() == (new File(Environment.getExternalStorageDirectory() + "")).toString())
                        firstLvl = true;
                } else {
                    File selectedFolder = new File(path + "/" + fileItem.fileName);
                    path = new File(selectedFolder + "");
                    firstLvl = false;
                }
                loadFiles();
                fileGridAdapter.notifyDataSetChanged();
            } else {
                FileGridItem fileGridItem = (FileGridItem) arg1;
                fileGridItem.checkBox.setChecked(true);
            }
        }
    });
    return rootView;
}

private void loadFiles() {
    listFileItem.clear();
    try {
        path.mkdirs();
    } catch (SecurityException e) {

    }
    if (path.exists()) {
        FilenameFilter filter = new FilenameFilter() {
            @Override
            public boolean accept(File dir, String filename) {
                File sel = new File(dir, filename);
                // Filters based on whether the file is hidden or not
                return (sel.isFile() || sel.isDirectory())
                        && !sel.isHidden();
            }
        };

        String[] fList = path.list(filter); 
        listFileItem = new ArrayList<FileItem>();
        for (int i = 0; i < fList.length; i++) {
            listFileItem.add(new FileItem(fList[i], path.getPath()));
        }

        if (!firstLvl) {
            listFileItem.add(new FileItem("up", path.getPath()));
        }
    } else {
    }
}

}

the anh
  • 41
  • 4

0 Answers0