Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:51:22+00:00 2026-06-10T00:51:22+00:00

I do not understand what is wrong I am use public class UrlArrayAdapter extends

  • 0

I do not understand what is wrong

I am use

  public class UrlArrayAdapter extends BaseAdapter {...      
         ArrayList<UrlItem> objects;

        UrlArrayAdapter(Context context, ListView urlListView,
                ArrayList<UrlItem> urlLists) {
objects = urlLists; ...



    //method
    public void deleteItem(int numberToDelete) {        
            objects.remove(numberToDelete);      
             notifyDataSetChanged();
        }

AND (the most interesting)

I get numberToDelete = 1

This line is then removed

enter image description here

but objects
enter image description here

and when numberToDelete = 0

This line is then removed

enter image description here

but objects
enter image description here

AND when numberToDelete = 2

objects

enter image description here

but after notifyDataSetChanged(); IndexOutOfBoundException

I already have a post … but I can not solve this problem

IndexOutOfBoundException when I use notifyDataSetChanged

stackoverflow.com/a/9260757/1568164 I am feeling that the situation is this, i use but not work

Then I get a position to further remove

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;

    }

My basis Activity where I call the removal line

public class DatabaseTable extends Activity {
    private Settings setting;
    private ArrayList<UrlItem> 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);
    }

}

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:51:24+00:00Added an answer on June 10, 2026 at 12:51 am

    the solution was simple.

    viewHolder.text
                        .setOnFocusChangeListener(new OnFocusChangeListener() {
                            public void onFocusChange(View v, boolean hasFocus) {
    

    did not work properly, redraw the list of focus has changed and deleted lines chaotic .. agonized for a week a decision was simple, left to fix

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not understand what is wrong with this query? Query tool does not
I do not understand how to use enumeration types. I understand what they are,
I really do not understand what I am doing wrong below. I have a
I use AsyncTask to change text of TextView like this: private class LongOperation extends
I simply could not understand why the following code does not work. What could
I do not understand why this error occurs...Is this a bug in XE, or
I do not understand pointers. Where can I learn more about them?
I simply do not understand why both works: this.timer.Tick += new EventHandler(timer_Tick); this.timer.Tick +=
I do not understand what environment a eval or exec statement executes in. You
I do not understand this error, do not generate error in JsonResult Test (),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.