Page 1 of 1

EditText input not where the cursor is(Doesn't seem to move the fo

#1 noneed52  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 10-March 12

Posted 10 March 2012 - 12:53 AM

This is problem with Android application.
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.

Is This A Good Question/Topic? 0
  • +

Replies To: EditText input not where the cursor is(Doesn't seem to move the fo

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,910
  • Joined: 06-March 08

Posted 10 March 2012 - 07:23 PM

Moved from Java Programming to Android Development forum
Was This Post Helpful? 0
  • +
  • -

#3 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Posted 10 March 2012 - 08:12 PM

No, you moved it to Android Tutorials :P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1