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

  • SEARCH
  • Home
  • 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 8160249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:10:27+00:00 2026-06-06T18:10:27+00:00

I want to remove an item from ListView , but I don’t know how

  • 0

I want to remove an item from ListView, but I don’t know how can I do it.

This is my code…

public void FLYNOTE_refresh() {
    int i;
    SharedPreferences Pref = getSharedPreferences("nnote", MODE_WORLD_READABLE); //созаётся файл настроек "nnote" и туда барыжиться вся хня
    key = Pref.getInt("number", 0); 
    key++;
    String lv_arr[] = new String[key];

    for (i = 0; i < key; i++) {
         lv_arr[i] = Pref.getString("n" + i, "none");           
    }

    textView1.setText(String.valueOf(key));

    listView1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
    listView1.setTextFilterEnabled(true);
}

I want to remove an item with 0 id,guide me to do that.

  • 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-06T18:10:28+00:00Added an answer on June 6, 2026 at 6:10 pm

    If you do not want to display item 0, simply adjust the size of lv_arr and change your for-loop:

    public void FLYNOTE_refresh() {
        int i;
        SharedPreferences Pref = getSharedPreferences("nnote", MODE_WORLD_READABLE); //созаётся файл настроек "nnote" и туда барыжиться вся хня
        key = Pref.getInt("number", 0); 
        String lv_arr[] = new String[key]; // One item smaller without "n0" 
    
        key++;
        for (i = 1; i < key; i++) {
            // Skip "n0" like this
            lv_arr[i - 1] = Pref.getString("n" + i, "none");           
        }
    
        textView1.setText(String.valueOf(key));
    
        listView1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lv_arr));
        listView1.setTextFilterEnabled(true);
    }
    

    If you want to remove items while the app is running I suggest using a List<String> rather than a String[]:

    public void FLYNOTE_refresh() 
    {
        int i;
        SharedPreferences Pref = getSharedPreferences("nnote", MODE_WORLD_READABLE); //созаётся файл настроек "nnote" и туда барыжиться вся хня
        key = Pref.getInt("number", 0); 
        key++;
        lv_arr = new ArrayList<String>(); 
    
        for (i = 1; i < key; i++) {
            lv_arr.add(Pref.getString("n" + i, "none"));           
        }
    
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lv_arr);
        listView1.setAdapter(adapter);
    
        listView1.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                lv_arr.remove(position);
                adapter.notifyDataSetChanged();
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If i have IEnumberable<Car> list and i want to remove an item from this
I want to remove an item from HashMap, by applying a criteria. Consider this
Using KnockoutJS, how can I remove an item from an observable array? I want
I have a std::list of boost::shared_ptr<T> and I want to remove an item from
I want to remove remove table row from table and subsequently remove the item
In Django you can remove items from a QuerySet by doing this as documented
I would like to know how to remove an item (which a user can
If I want to remove an item from my list view by tapping it,
I choose an item to remove from my ListView . And after the Item
I want to remove an item from the result of a LINQ query before

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.