Can not assign string data from arraylist to textview
<p>I have an <code>ArrayList</code> in my <code>mainActivity</code> which stores <code>String</code> data. After declaring the <code>ArrayList</code> data are inserted from a database to the <code>ArrayList</code>. then when user clicks any element on <code>ListView</code>. I am trying to get data from the <code>ArrayList</code> using index value. Below is the code I am using. </p>

<pre><code>ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
list.add("rice");
list.add("wheat");
</code></pre>

<p>Then I try to get data like </p>

<pre><code>String data=list.get(0);
mtTextView.setText(data); //error is shown on this line
</code></pre>

<p>Where is the error and why I am getting the error. I cant find any wrong with the code</p>

<p>I followed below thread </p>

<p><a href="https://stackoverflow.com/questions/23216577/assign-arraylist-value-to-textview">assign arraylist value to textview</a></p>

<p>It tells to convert to string (as they had int value) but already i have string variable. </p>