Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting text in view holder text view from an arraylist
    primarykey
    data
    text
    <p>i am working on implementing list view, i have user BaseAdapter class.i am trying to setText in holder's text view field from an array list but without any success.Problem is in getView method's <code>HashMap&lt;String, ArrayList&lt;String&gt;&gt; map = list.get(position); holder.txtFirst.setText(map.get(FIRST_COLUMN).toString());</code> part.<br> <strong>EDIT:</strong> my main activity class(<strong>postExecute method</strong>) where i am setting up key and values for list adapter class. code is as : </p> <pre><code>protected void onPostExecute(ArrayList&lt;ArrayList&lt;String&gt;&gt; result) { ArrayList&lt;String&gt; conceptID = new ArrayList&lt;String&gt;(result.get(0)); ArrayList&lt;String&gt; conceptDesc = new ArrayList&lt;String&gt;(result.get(1)); listForSearchConcepts = new ArrayList&lt;HashMap&lt;String,ArrayList&lt;String&gt;&gt;&gt;(); HashMap&lt;String, ArrayList&lt;String&gt;&gt; temp = new HashMap&lt;String,ArrayList&lt;String&gt;&gt;(); temp.put(FIRST_COLUMN,conceptID); listForSearchConcepts.add(temp); temp.put(SECOND_COLUMN,conceptDesc); listForSearchConcepts.add(temp); listviewAdapter adapter = new listviewAdapter(MainActivity.this, listForSearchConcepts); listView.setAdapter(adapter); }` </code></pre> <p>However below is my code of adapter class :</p> <pre><code>public class listviewAdapter extends BaseAdapter { public ArrayList&lt; HashMap &lt; String,ArrayList &lt; String &gt; &gt; &gt; list; Activity activity; public listviewAdapter(Activity activity, ArrayList&lt;HashMap&lt;String,ArrayList&lt;String&gt;&gt;&gt; listForSearchConcepts) { super(); this.activity = activity; this.list = listForSearchConcepts; } public int getCount() { // TODO Auto-generated method stub return list.size(); } public Object getItem(int position) { // TODO Auto-generated method stub return list.get(position); } public long getItemId(int position) { // TODO Auto-generated method stub return 0; } private class ViewHolder { TextView txtFirst; TextView txtSecond; TextView txtThird; TextView txtFourth; } public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub // TODO Auto-generated method stub ViewHolder holder; LayoutInflater inflater = activity.getLayoutInflater(); if (convertView == null) { convertView = inflater.inflate(R.layout.listview_row, null); holder = new ViewHolder(); holder.txtFirst = (TextView) convertView.findViewById(R.id.FirstText); holder.txtSecond = (TextView) convertView.findViewById(R.id.SecondText); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } HashMap&lt;String, ArrayList&lt;String&gt;&gt; map = list.get(position); holder.txtFirst.setText(map.get(FIRST_COLUMN).toString()); //holder.txtSecond.setText(map.get(SECOND_COLUMN).get(1)); //holder.txtThird.setText(map.get(THIRD_COLUMN)); //holder.txtFourth.setText(map.get(FOURTH_COLUMN)); return convertView; } </code></pre> <p>}</p> <p>i am also attaching screenshot of what actually i am getting on running the application:<br> <img src="https://i.stack.imgur.com/VQ87P.png" alt="out put list view"></p> <p>any suggestion?<br> thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload