Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding item to ListAdapter causes exception
    primarykey
    data
    text
    <p>I'm trying to use a list view, and when I add an item to the ArrayList of its ListAdapter and call notifyDataSetChanged, it throws an exception. Calling the addItem routine below will throw an exception.</p> <p>The message says Source not Found, and then this: // Compiled from DataSetObservable.java (version 1.5 : 49.0, super bit) // Signature: Landroid/database/Observable; public class android.database.DataSetObservable extends android.database.Observable {</p> <p>// Method descriptor #8 ()V // Stack: 3, Locals: 1 public DataSetObservable(); 0 aload_0 [this] 1 invokespecial android.database.Observable() [1] 4 new java.lang.RuntimeException [2] 7 dup 8 ldc [3] 10 invokespecial java.lang.RuntimeException(java.lang.String) [4] 13 athrow Line numbers: [pc: 0, line: 5] Local variable table: [pc: 0, pc: 14] local: this index: 0 type: android.database.DataSetObservable</p> <p>My initialization code:</p> <pre><code> tickerList = (ListView)findViewById(R.id.ListView01); tickerModel = new StockAdapter(stocks); tickerList.setAdapter(tickerModel); </code></pre> <p>I've included my custom adapter class. (Modified from an online example)</p> <pre><code>private class StockAdapter extends BaseAdapter { private ArrayList &lt;Stockdata&gt;mData = new ArrayList&lt;Stockdata&gt;(); private LayoutInflater mInflater; public StockAdapter(ArrayList&lt;Stockdata&gt;rows) { mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); mData = rows; } public void addItem(Stockdata item) { mData.add(item); notifyDataSetChanged(); } @Override public int getCount() { return mData.size(); } @Override public Stockdata getItem(int position) { return mData.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { System.out.println("getView " + position + " " + convertView); ViewHolder holder = null; if (convertView == null) { convertView = mInflater.inflate(R.layout.row, null); holder = new ViewHolder(); holder.textView = (TextView)convertView.findViewById(R.id.SYMBOL_CELL); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } holder.textView.setText(mData.get(position).getSymbol()); return convertView; } } public static class ViewHolder { public TextView textView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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