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 7187865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:56:28+00:00 2026-05-28T18:56:28+00:00

I have got a main extending adapter which adds rows when user clicks on

  • 0

I have got a main extending adapter which adds rows when user clicks on a button. In the adapter, I got a remove item button and a checkbox. How do I remove the item from the list?

public class main extends Activity{

ArrayList<String> noteList = new ArrayList<String>();
FancyAdapter aa = null;

Button calculate;
EditText result;
String total;
String name;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final Spinner spinner = (Spinner)findViewById(R.id.spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.spinner_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    ListView myListView = (ListView)findViewById(R.id.noteList);
    aa = new FancyAdapter();

    final EditText price = (EditText)findViewById(R.id.price);
    final EditText name1 = (EditText)findViewById(R.id.name);
    myListView.setAdapter(aa);

    myListView.setOnItemClickListener(new OnItemClickListener() {
       public void onItemClick(AdapterView<?> arg0, View arg1,
                 int position, long arg3) {

        }
    });

    Button btnSimple = (Button)findViewById(R.id.btnSimple);        

    btnSimple.setOnClickListener(new OnClickListener() {
        public void onClick(View v)
        {
            try
            {
            double totalPrice = Double.parseDouble(price.getText().toString());
            int position = spinner.getSelectedItemPosition();
            name = name1.getText().toString();

            if(position == 0)
            {
                totalPrice = totalPrice * 1.07;
                total = String.valueOf(totalPrice);
                System.out.println(total);
            }
            else
            {
                totalPrice = (totalPrice * 1.1)*1.07;
                total = String.valueOf(totalPrice);
                System.out.println(total);
            }
            String wholeString = name + ":$" +total;
            noteList.add(0, wholeString); 
            System.out.println(total);
            name1.setText("");
            price.setText("");
            aa.notifyDataSetChanged();
            }
            catch (Exception e)
            {

            }
        }
    });        

}

class FancyAdapter extends ArrayAdapter<String>
{
    Button calculate;
    EditText price;
    EditText result;

    FancyAdapter()
    {
        super(main.this, android.R.layout.simple_list_item_1, noteList);
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        View row = convertView;     

        if(row == null)
        {
            LayoutInflater inflater = getLayoutInflater();
            row = inflater.inflate(R.layout.custom_list_item, null);
        }

        StringTokenizer tokens = new StringTokenizer(noteList.get(position), ":");
        String first = tokens.nextToken();
        String second = tokens.nextToken();
        row.getTag();
        ((TextView)row.findViewById(R.id.nametv)).setText(first);
        ((EditText)row.findViewById(R.id.result)).setText(second);

        Button deleteButton = (Button) row.findViewById(R.id.button);

        deleteButton.setTag(position);

        deleteButton.setOnClickListener(
                new Button.OnClickListener() {
                    public void onClick(View v) {

                    }
                }
            );
        return (row);
    }
}

}
  • 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-05-28T18:56:29+00:00Added an answer on May 28, 2026 at 6:56 pm

    remove list item, and invoke notifyDataSetChanged();

    public View getView(int position, View convertView, ViewGroup parent)
        {
            View row = convertView;     
    
            if(row == null)
            {
                LayoutInflater inflater = getLayoutInflater();
                row = inflater.inflate(R.layout.custom_list_item, null);
            }
    
            StringTokenizer tokens = new StringTokenizer(noteList.get(position), ":");
            String first = tokens.nextToken();
            String second = tokens.nextToken();
            row.getTag();
            ((TextView)row.findViewById(R.id.nametv)).setText(first);
            ((EditText)row.findViewById(R.id.result)).setText(second);
    
            Button deleteButton = (Button) row.findViewById(R.id.button);
    
            deleteButton.setTag(position);
    
            deleteButton.setOnClickListener(
                    new Button.OnClickListener() {
                        public void onClick(View v) {
                            noteList.remove(position);
                            notifyDataSetChanged();
                        }
                    }
                );
            return (row);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a datatable which contains many columns in which three are main:
I've got a textView on my main view. I have got a button, on
I created view-based application. I have got a sampleGameViewContrioller.xib, which contains main View, and
In Unix, I have got three main files. One of them is a library
I've got main folder: c:\test And there I have 2 folders: Movies and Photos.
Presently, we've got several main projects each in their own repository. We will have
I've got a situation where I have a main form that pops up an
We have got loads of options for php + MySQL + Apache combo... Which
I have got a python script which is creating an ODBC connection. The ODBC
My main field is .Net but recently I have got something to do with

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.