Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8943515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:47:25+00:00 2026-06-15T11:47:25+00:00

I am filling a ListView with ArrayAdapter in an AsyncTask. But everytime it only

  • 0

I am filling a ListView with ArrayAdapter in an AsyncTask.
But everytime it only fills in one item.

Could someone explain me why?

onCreate

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.connected_download);
    Log.v("string", "test6");

    runOnUiThread(new Runnable() {
        public void run() {
            str_profil = getIntent().getStringExtra("profil");
            str_server = getIntent().getStringExtra("server");
            str_port = getIntent().getStringExtra("port");
            str_user = getIntent().getStringExtra("user");
            str_password = getIntent().getStringExtra("pw");
            new connection_test().execute();
        }
    });
}

AsyncTask

    private class connection_test extends AsyncTask<String, Void, String> {

    protected void onPreExecute(){
        dialog = ProgressDialog.show(connected_download.this, null, "Erstelle Vorschau. Bitte warten...");
    }

    protected String doInBackground(String... connection) {
                listftpitems();
            return null;
    }

    protected void onPostExecute(String result) {
        dialog.dismiss();
    }
}

listftpitems

    public void listftpitems(){
    try {
        ftpClient.setConnectTimeout(15000);
        Integer int_port = Integer.parseInt(str_port);
        ftpClient.connect(InetAddress.getByName(str_server), int_port);
        ftpClient.login(str_user, str_password);
        ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        ftpClient.enterLocalPassiveMode();
        System.out.println("status :: " + ftpClient.getStatus());
        System.out.println("FTPClient : " + "Offen");

    } catch (Exception e) {
        e.printStackTrace();
    } 

    final ArrayList<String> your_array_list = new ArrayList<String>();
    final ListView lv = (ListView) findViewById(R.id.list_download);
    final FTPFile[] files;
    try {

        files = ftpClient.listFiles();

        for (FTPFile file : files) {
            String details = file.getName();
            your_array_list.add(details);
            Log.v("string", details);
        }

        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(connected_download.this,android.R.layout.simple_list_item_1, your_array_list);

        runOnUiThread(new Runnable() {
            public void run() {
            lv.setAdapter(arrayAdapter); 
            }
        });



    }catch (IOException e1) {
        e1.printStackTrace();
    }

}

LogCat (take a look to the Log.v(“string”, details); on listftpitems) so its correct

12-05 11:34:24.650: D/AbsListView(23249): Get MotionRecognitionManager
12-05 11:34:24.650: V/string(23249): test6
12-05 11:34:24.695: D/dalvikvm(23249): GC_FOR_ALLOC freed 64K, 9% free 13420K/14599K, paused 13ms, total 15ms
12-05 11:34:24.945: D/dalvikvm(23249): GC_CONCURRENT freed 29K, 8% free 13813K/14983K, paused 11ms+5ms, total 28ms
12-05 11:34:25.480: I/System.out(23249): status :: 211-Status of 'ProFTPD'
12-05 11:34:25.480: I/System.out(23249):  Connected from 213.55.184.193 (213.55.184.193)
12-05 11:34:25.480: I/System.out(23249):  Logged in as ftp031220
12-05 11:34:25.480: I/System.out(23249):  TYPE: BINARY, STRUcture: File, Mode: Stream
12-05 11:34:25.480: I/System.out(23249):  No data connection
12-05 11:34:25.480: I/System.out(23249): 211 End of status
12-05 11:34:25.480: I/System.out(23249): FTPClient : Offen
12-05 11:34:26.095: V/string(23249): anon_ftp
12-05 11:34:26.095: V/string(23249): bin
12-05 11:34:26.095: V/string(23249): cgi-bin
12-05 11:34:26.095: V/string(23249): conf
12-05 11:34:26.095: V/string(23249): error_docs
12-05 11:34:26.095: V/string(23249): httpdocs
12-05 11:34:26.095: V/string(23249): httpsdocs
12-05 11:34:26.095: V/string(23249): mivadata
12-05 11:34:26.095: V/string(23249): pd
12-05 11:34:26.095: V/string(23249): private
12-05 11:34:26.095: V/string(23249): statistics
12-05 11:34:26.095: V/string(23249): subdomains
12-05 11:34:26.095: V/string(23249): vault_scripts
12-05 11:34:26.095: V/string(23249): web_users

picture from my phone

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:47:27+00:00Added an answer on June 15, 2026 at 11:47 am

    you are doing everything in current code with wrong way like you are trying to Use runOnUiThread from doInBackground .change your code as:


    Change listftpitems as:

    public ArrayList<String> listftpitems(){
    try {
            ArrayList<String> your_array_list = new ArrayList<String>();
            ftpClient.setConnectTimeout(15000);
            Integer int_port = Integer.parseInt(str_port);
            ftpClient.connect(InetAddress.getByName(str_server), int_port);
            ftpClient.login(str_user, str_password);
            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
            ftpClient.enterLocalPassiveMode();
            System.out.println("status :: " + ftpClient.getStatus());
            System.out.println("FTPClient : " + "Offen");
    
        } catch (Exception e) {
            e.printStackTrace();
        } 
        final FTPFile[] files;
        try {
            files = ftpClient.listFiles();
            for (FTPFile file : files) {
                String details = file.getName();
                your_array_list.add(details);
                Log.v("string", details);
            }
        }catch (IOException e1) {
            e1.printStackTrace();
        }
    
    return your_array_list;
    }
    

    Change AsyncTask as:

    private class connection_test extends AsyncTask<String, Void, String> {
       ArrayList<String> temparrlist = new ArrayList<String>();
        protected void onPreExecute(){
            dialog = ProgressDialog.show(connected_download.this, null, 
                                     "Erstelle Vorschau. Bitte warten...");
        }
    
        protected ArrayList<String> doInBackground(String... connection) {
                  temparrlist=listftpitems();
                return temparrlist;
        }
    
        protected void onPostExecute(ArrayList<String> result) {
           ArrayAdapter<String> arrayAdapter = 
                    new ArrayAdapter<String>(connected_download.this,
                                  android.R.layout.simple_list_item_1, 
                                  result);
           lv.setAdapter(arrayAdapter); 
            dialog.dismiss();
        }
    }
    

    Change your Activity onCreate as:

    ListView lv ;
        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.connected_download);
        Log.v("string", "test6");
    
                str_profil = getIntent().getStringExtra("profil");
                str_server = getIntent().getStringExtra("server");
                str_port = getIntent().getStringExtra("port");
                str_user = getIntent().getStringExtra("user");
                str_password = getIntent().getStringExtra("pw");
            lv= (ListView) findViewById(R.id.list_download);
                new connection_test().execute("");
    }
    

    and plz read some basic of Android from :

    http://developer.android.com/guide/components/index.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my applicatio i have 1 listview,filling data from database using arrayadapter. Here is
Currently my ListView is filling up with the given String[] but I wanted to
Im filling in dropdowns with ajax'd info -- sometimes (when editing) I not only
I am filling a GridView with the data table but on each row I
I am filling a listview from names of a database. That is all working
In my webpage i use the following in order filling the listview control <asp:ListView
I have a division filling it with panels. But inside the division the panels
I am filling in my listview with a SimpleCursorAdapter . By using getView() I
I have a ListView that I'm filling with an ObservableCollection I'm filtering the list
i have an app that is showing data in listview ,but i want first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.