简体   繁体   中英

How to store EditText input into existing ArrayList

I am trying to take the input from an EditText field and store it into an existing ArrayList. I have errors in my code but I cannot find them. Any help would be greatly appreciated.

sButton = (Button) this.findViewById(R.id.button2);
    eText = (EditText) this.findViewById(R.id.editText1);

    sButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {

             Log.v("EditText", eText.getText().toString());
             eText.setText(getText(0));

To get it in an arraylist you do this.. But not sure if that's what you're stuck at atm.

Top of your class :

ArrayList<string> list = new ArrayList<string>();

and in your method

     @Override
     public void onClick(View view) {
        list.add(eText.getText().toString());
     }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM