I'm currently implementing an Activity where EditText box is added dynamically with the click of an add button.
The adding works perfectly but the problem is as I said in the title. The input is always inserted to the first EditText box....
However, problem gets solved when the phone goes to sleep mode and turned back on. Then everything works as intended very strange..... I'm just guessing but for some reason focus pointer doesn't get updated
Here's my code
within addEvent method I add new EditText like this
EditText amount = new EditText(this);
RelativeLayout.LayoutParams etLParams = new RelativeLayout.LayoutParams(
400, LayoutParams.WRAP_CONTENT);
etLParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
amount.setInputType(InputType.TYPE_CLASS_NUMBER);
amount.setLayoutParams(etLParams);
amount.setId(eventNumber);
amount.setSingleLine();
amount.setFocusable(true);
amount.requestFocus();
amount.setCursorVisible(true);
amount.setGravity(Gravity.RIGHT);
amount.setText("0");
amount.setSelection(1);
amount.addTextChangedListener(new CustomTextWatcher(amount));
When add button is pressed
case ADD_EVENT:
mEvents.removeViewAt(mEvents.getChildCount()-1);
LinearLayout temp = (LinearLayout) members.getChildAt(0);
members.removeAllViews();
RelativeLayout old = new RelativeLayout(this);
old = (RelativeLayout) mEvents.getChildAt(eventNum-1);
((Button) old.getChildAt(2)).setText("remove");
((Button) old.getChildAt(2)).setId(REMOVE_EVENT);
mEvents.addView(addEvents(++eventNum)); //This is where adds new EditText box
mEvents.addView(addEndEvent());
members.addView(temp);
members.addView(addEventCheck(0, 0));
members.addView(addMemberBtn());
break;
If you need more information please do not hesitate to ask.
Thanks in advance.





MultiQuote




|