Note that there are some explanatory texts on larger screens.

plurals
  1. POnotifyDataSetChanged() - IndexOutOfBoundException
    primarykey
    data
    text
    <p>I do not understand what is wrong</p> <p>I am use </p> <pre><code> public class UrlArrayAdapter extends BaseAdapter {... ArrayList&lt;UrlItem&gt; objects; UrlArrayAdapter(Context context, ListView urlListView, ArrayList&lt;UrlItem&gt; urlLists) { objects = urlLists; ... //method public void deleteItem(int numberToDelete) { objects.remove(numberToDelete); notifyDataSetChanged(); } </code></pre> <p>AND (the most interesting)</p> <p>I get numberToDelete = 1</p> <p>This line is then removed</p> <p><img src="https://i.stack.imgur.com/IGzI8.png" alt="enter image description here"></p> <p>but objects <img src="https://i.stack.imgur.com/5ExaP.png" alt="enter image description here"></p> <p>and when numberToDelete = 0</p> <p>This line is then removed</p> <p><img src="https://i.stack.imgur.com/IYBNU.png" alt="enter image description here"></p> <p>but objects <img src="https://i.stack.imgur.com/43Wir.png" alt="enter image description here"></p> <p>AND when numberToDelete = 2</p> <p>objects</p> <p><img src="https://i.stack.imgur.com/kzLVx.png" alt="enter image description here"></p> <p><strong>but after notifyDataSetChanged(); IndexOutOfBoundException</strong> </p> <p>I already have a post ... but I can not solve this problem </p> <p><a href="https://stackoverflow.com/questions/11990399/indexoutofboundexception-when-i-use-notifydatasetchanged">IndexOutOfBoundException when I use notifyDataSetChanged</a></p> <p>stackoverflow.com/a/9260757/1568164 I am feeling that the situation is this, i use but not work </p> <p>Then I get a position to further remove</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { // Planet to display UrlItem urlItem = (UrlItem) this.getItem(position); ViewHolder viewHolder = null; if (convertView == null) { convertView = lInflater.inflate(R.layout.database_table_item, null); viewHolder = new ViewHolder(); viewHolder.checkbox = (CheckBox) convertView .findViewById(R.id.checkBox1); viewHolder.checkbox.setOnCheckedChangeListener(listener1); viewHolder.text = (EditText) convertView .findViewById(R.id.editText1); viewHolder.text .setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { int getPosition = (Integer) v.getTag(); if (!hasFocus) { final EditText Caption = (EditText) v; // urlLists objects.get(getPosition).setUrl( Caption.getText().toString()); } else { DatabaseTable.setPosition(getPosition); // This is a future for "numberToDelete" } } }); convertView.setTag(viewHolder); convertView.setTag(R.id.checkBox1, viewHolder.checkbox); convertView.setTag(R.id.editText1, viewHolder.text); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.text.setTag(position); viewHolder.text.setText(urlItem.getUrl()); viewHolder.checkbox.setTag(position); viewHolder.checkbox.setChecked(urlItem.getUse()); return convertView; } </code></pre> <p>My basis Activity where I call the removal line</p> <pre><code>public class DatabaseTable extends Activity { private Settings setting; private ArrayList&lt;UrlItem&gt; urlLists; private ListAdapter uAdapter; private ListView urlListView; static int position; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.database_table_list); LBD conection = new LBD(this); conection.open(); setting = conection.tblSettings(); setting.create(); urlLists = setting.selectRssTable(); urlListView = (ListView) findViewById(R.id.listView1); uAdapter = new UrlArrayAdapter(DatabaseTable.this, urlListView, urlLists); urlListView.setAdapter(uAdapter); urlListView.setItemsCanFocus(true); } public static void setPosition(int pos) { position = pos; } @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, 2, 2, "Delete URL"); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 2: ((UrlArrayAdapter) uAdapter).deleteItem(position); break; } return super.onOptionsItemSelected(item); } } </code></pre> <p>continuing the theme I experimented and concluded that the strings in the list of adapters have little to do with the fact that the output to the screen, so the challenge is changing. need to understand how to delete rows from the screen</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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