Currently I am using a string array to hold some data that is used by my adapter, but I need to use the data in a listof:

Currently I am using this:

```
<string-array name="vegetables">
<item> Onion </item>
<item> Chillis </item>
<item> Tomatoes </item>
<item> Garlic Beans</item>

```

This is the data format I need to use:

```
val VegName  = listOf(
Veg(0, "Onion", R.drawable.onion),
Veg(1, "Chillis", R.drawable.chilli),
Veg(2, "Tomatoes (indoor)", R.drawable.tomatoe),
Veg(3, "Garlic", R.drawable.garlic) 

```

)

**The adapter code:**

```
class SearchActivity : AppCompatActivity() {
private lateinit var toolbar: Toolbar
lateinit var adapter: ArrayAdapter<*>
private lateinit var listView: ListView
private lateinit var emptyView: TextView

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.search_main)
    title = "Search Veg"
    toolbar = findViewById(R.id.toolbar)
    listView = findViewById(R.id.listView)
    emptyView = findViewById(R.id.emptyView)
    adapter = ArrayAdapter<Any?>(this, android.R.layout.simple_list_item_1,
        resources.getStringArray(R.array.vegetables))
    adapter = ArrayAdapter<Any?>(this, android.R.layout.simple_list_item_1,
        resources.getStringArray(R.array.vegetables)) // I THINK THIS IS WHERE IT NEEDS CHANGING?
    listView.adapter = adapter
    listView.onItemClickListener = OnItemClickListener { adapterView, _, i, _ ->
        Toast.makeText(this@SearchActivity, adapterView.getItemAtPosition(i).toString(),
            Toast.LENGTH_SHORT).show()
    }
    listView.emptyView = emptyView
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
    menuInflater.inflate(R.menu.nav_menu, menu)
    menuInflater.inflate(R.menu.menu, menu)
    val search = menu.findItem(R.id.appSearchBar)
    val searchView : SearchView? = search?.actionView as SearchView?

    searchView?.queryHint = "Search"

    listView.setOnItemClickListener(OnItemClickListener { parent, view, position, id ->
        val intent = Intent()
        val theItemClicked = String()
        Toast.makeText(this@SearchActivity, listView.getItemAtPosition(position).toString(),
            Toast.LENGTH_SHORT).show()
        intent.putExtra("result",  listView.getItemAtPosition(position).toString() )
        intent.putExtra("position", position.toString())
        setResult(RESULT_OK, intent)
        finish()
    })
    searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
        override fun onQueryTextSubmit(query: String?): Boolean {
            return false
        }
        override fun onQueryTextChange(newText: String?): Boolean {
            adapter.filter.filter(newText)
            return true
        }
    })
    return super.onCreateOptionsMenu(menu)
}

```

}

Any help on changing the data format would be really appreciated!

Cheers