JAVA/android_studio 2024. 9. 16. 11:09

 

https://stackoverflow.com/questions/31279216/how-to-add-an-item-to-a-listview-with-each-button-click

 

How to add an item to a ListView with each Button click

This is the code I'm working on, it should simply add an item in a ListView (w/ array) each time the Button is clicked. The text inserted by the user on a EditText should be added to the list each ...

stackoverflow.com

 

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

        buttonPlus.setOnClickListener(
                new Button.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        arrayNames.add(0, namesText.getText().toString());
                        adapterNames.notifyDataSetChanged();
                        namesText.setText("");

                    }
                }
        );

 

 

 

posted by cskimair
: