B
B
BoxMan362015-01-25 00:27:28
Android
BoxMan36, 2015-01-25 00:27:28

How to populate a ListView from a text file?

Hello. I have such a question, is it possible to fill ListView in androyd somehow from a text file?
In java, I can easily find and read a text file, but in android something doesn’t work. d8d511083355457a9a07b5dce3e4ace7.png
Here interests from the file input.txt it is possible to add the text in ArrayAdapter?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
one pavel, 2015-01-25
@BoxMan36

You can, transfer input to the asset folder of the project. Through the Activity, get the AssetManager and read the contents of the file through it with the usual InputStream.

O
Oleg Gamega, 2015-01-25
@gadfi

in the res folder resources, to work like with a file, put it in an asset, although if there is not much data, you can use an array of strings

<string-array name="items">
        <item>0 item</item>
        <item>1 item</item>
        <item>2 item</item>
        ....
    </string-array>

String array[] = getResources().getStringArray(R.array.items);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question