0

I have a EditText, ListView and Button.

My requirement is on click of the button, I wanted the text from edittext to append in the list.

  • I want the code on button click.
  • I tried and I get unsupported error.

Can anybody help me in solving this issue?

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
user940371
  • 35
  • 1
  • 3
  • 13
  • 2
    There are sooo many different ways to do this. Post your code! – Bondax Apr 03 '13 at 05:16
  • 1
    Post some possible code of button click listener if you have tried. – Paresh Mayani Apr 03 '13 at 05:17
  • i think you have to do some googling before post here: check this links : http://vikaskanani.wordpress.com/2011/07/27/android-focusable-edittext-inside-listview/ and http://stackoverflow.com/questions/1998483/listview-dynamic-add-item – Dhaval Parmar Apr 03 '13 at 05:19
  • @DhavalSodhaParmar That's not his requirement I think. 2nd link will help him out I think. – Paresh Mayani Apr 03 '13 at 05:20
  • @PareshMayani : he said "My requirement is on click of the button, I wanted the text from edittext to append in the list." --> http://stackoverflow.com/a/10296747/1168654 – Dhaval Parmar Apr 03 '13 at 05:22

1 Answers1

2

Add this code to Activity.onCreate():

adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1);
listView.setAdapter(adapter);

Add this code to Button's OnClickListener:

String text = eidtText.getText().toString();
adapter.add(text);
adapter.notifyDataSetChanged();