I have an ArrayList in my mainActivity which stores String data. After declaring the ArrayList data are inserted from a database to the ArrayList. then when user clicks any element on ListView. I am trying to get data from the ArrayList using index value. Below is the code I am using.
ArrayList<String> list = new ArrayList<String>();
list.add("rice");
list.add("wheat");
Then I try to get data like
String data=list.get(0);
mtTextView.setText(data); //error is shown on this line
Where is the error and why I am getting the error. I cant find any wrong with the code
I followed below thread
assign arraylist value to textview
It tells to convert to string (as they had int value) but already i have string variable.