0

enter image description hereI am a newbie android programmer, and now i learn how to build android apps. But i want to make a ListView via strings.xml, and after that i want to modify this listview with a thumbnail, anyone can help me? and this is mock up of my application apps

  • Look at [this answer](http://stackoverflow.com/questions/32070975/populate-listview-with-arraylist-having-string-array-as-elements#answer-32071272). Just grab the string array from your xml file instead of creating it manually – AesSedai101 Jul 12 '16 at 15:04
  • they used baseadapter, but in the same application i used it too, so if i build apk android studio give me error message... so can i build listview without adapter? – Maju Sumanto Jul 12 '16 at 15:12
  • No, to populate a listview you need to use an adapter – AesSedai101 Jul 12 '16 at 15:13
  • so can i use adapter twice in the same program? because above the listview i build a calendar, and this calendar use adapter too... please help me... – Maju Sumanto Jul 12 '16 at 15:18

1 Answers1

0

Write the following inside your activity:

    ListView listView = (ListView) findViewById(R.id.listView);
    String[] items = getResources().getStringArray(R.array.listKegiatan);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items);
    listView.setAdapter(adapter);
Mahmoud Ibrahim
  • 1,057
  • 11
  • 20
  • what the function of : ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items); but i used adapter in the same activity before. can I used adapter twice in same activity? – Maju Sumanto Jul 12 '16 at 15:19
  • In Android development, any time we want to show a vertical list of scrollable items we will use a ListView which has data populated using an Adapter. The simplest adapter to use is called an ArrayAdapter. You shouldn't use two adapter in the same activity. – Mahmoud Ibrahim Jul 12 '16 at 15:29
  • Check the first answer in this question http://stackoverflow.com/questions/19079400/arrayadapter-in-android-to-create-simple-listview it will help you to understand the ArrayAdapter. – Mahmoud Ibrahim Jul 12 '16 at 15:34
  • thank you for your explanation, i want to build an application which is contains calendar and under the calendar display the event... so when i build the calendar i use the adapter... and if i want to make a listview under the calendar should i use another adapter? – Maju Sumanto Jul 12 '16 at 15:46
  • You are welcome. Can you give us a screen shoot of the screen that you want to implement in your app, to can help you ? – Mahmoud Ibrahim Jul 12 '16 at 15:52
  • yes i can, i already edit the question with my mockup application... so you can see above... hopefuly you can help me to solve this problem – Maju Sumanto Jul 12 '16 at 16:04
  • If you use the 4 above line of my answer for implement the bottom list of items of your mock up, you will get a list of items without thumbnail. but, if you want to make a list of items with a thumbnails, you have to make your own custom adapter not the ArrayAdapter. Check the following two URLs http://stackoverflow.com/questions/8166497/custom-adapter-for-list-view http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/ it will help you to understand and implement custom adapter. – Mahmoud Ibrahim Jul 12 '16 at 16:27