-2

I was created edittext by button click I was set id for edittext by method edittext.setid(in) But i dont get id of it when i want to get string in it. How to get string in edittext was created by button click? Help me

  • You could try adding the button in the xml layout and just have the visibility=gone. Then on the button click, you can make it visible, and you'll have the button ID – user1282637 Jul 30 '14 at 13:57
  • 1
    please post some code – Opiatefuchs Jul 30 '14 at 13:58
  • Try this Link: http://stackoverflow.com/questions/5923587/how-to-get-data-from-each-dynamically-created-edittext-in-android – VegeOSplash Jul 30 '14 at 14:30
  • Just hold a reference to it and get text from that reference, and would be a lot better if you post what you've done, so we can actually help you – elmorabea Jul 30 '14 at 15:23

2 Answers2

0

Your question is after creating the EditText you want to know how to get the input? If this is the question you have to declare EditText as global and then get an input usually for example:

String value = youredittext.getText().toString();
Ludger
  • 362
  • 2
  • 16
0

There are two ways to do it:

1) Save value with your editText when you create this view EditText mEditText = new EditText();

then you can get text value mEditText.getText().toString();

2) Set id:

EditText mEditText = new EditText();
mEditText.setID(SET_MY_ID);

then you can find this

EditText mEditText = findViewById(SET_MY_ID);
mEditText.getText().toString();

About id generation read Android: View.setID(int id) programmatically - how to avoid ID conflicts?

Community
  • 1
  • 1
QArea
  • 4,769
  • 1
  • 10
  • 22