开发者

how to dynamically display the EditText?

i'm new to android. So can any one help me to get the following, when i enter the number in a EditText, the entered no.of EdidText should be appear dynamically. For example if i entered 3 in a EditText then, 3 EditT开发者_如何学Goext(no.of) have to be shown on the screen. How can i show this?


You need to add a TextWatcher to your EditText by calling EditText.addTextChangedListener(). Then in your TextWatcher wait for calls to afterTextChanged and count the characters and update your title. This will be easier if you make your Activity implement the the TextWatcher interface itself.


Add layout to your xml where you want to display the Edittext. Then create the Layout variable e.g

LinearLayout ll = (LinearLayout)findViewById(R.id...);

and create new textboxes and add to the linearlayout e.g

EditText[] edit = new EditText[]();
EditText[] edit= new EditText[entered number];

initialize the variables in the loop by new Edittext(context); and add each one to the Layout

`ll.addView(edit[iterator]);`
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜