Listview of simple files does not run

Asked

Viewed 27 times

0

I have an application that at a certain time the user will list the contents of the folder containing some pdf’s that will be opened from this listing, however I can’t list the contents of the folder

package com.app.login_basic;

import android.app.ListActivity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class OpenFilePDF extends ListActivity {

ListView listview;
private File file;
private List<String> minhaLista;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_openfile);

    listview = findViewById(R.id.lv);
    //prencher a lista de um adapter



   minhaLista = new ArrayList<String>();

    String root_sd = 
 Environment.getExternalStorageDirectory().toString();
    file = new File(root_sd + "/pdf");
    File list[] = file.listFiles();

    for (int i = 0; i < list.length; i++) {
        minhaLista.add(list[i].getName());
    }

    setListAdapter(new ArrayAdapter<String>(this,

            android.R.layout.simple_list_item_1, minhaLista));
   }

}
  • I saw in chat that this model passed above has to make modifications, IE, was passed as an Abstract model, which only serves to illustrate the use.

  • https://chat.stackexchange.com/rooms/20581/discussion-between-war-lock-and-lollipop ...I didn’t change anything at the end &#Xainstead of the arrayadapter

  • I put it as I thought it was right, it also says here: https://stackoverflow.com/questions/32598489/list-view-asset-folders

  • all options I have lead me to error: Cannot resolve method 'setListAdapter(android.widget.Simpleadapter)'

  • updated extends to extend his class but it didn’t even work.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.