Have EditText selected for editing

Put your problem here if it does not fit any of the other categories.

Have EditText selected for editing

Postby ramgraph1 » Tue Jan 22, 2008 2:21 pm

I would like to have some text in an EditText selected so that as soon as the user starts typing the text that is there as a default gets deleted and replaced with whatever the user types. The way I am using EditText, if there is a default text, you need to go to the end of it and delete it letter by letter before typing your text. Is there a way to do what I want??
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Top

Re: Have EditText selected for editing

Postby kbkbkb » Tue Jan 22, 2008 2:28 pm

ramgraph1 wrote:I would like to have some text in an EditText selected so that as soon as the user starts typing the text that is there as a default gets deleted and replaced with whatever the user types. The way I am using EditText, if there is a default text, you need to go to the end of it and delete it letter by letter before typing your text. Is there a way to do what I want??


try this in main.xml

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <EditText
  2.  
  3. id="@+id/edittext"
  4.  
  5. android:text=""          
  6.  
  7. >
  8.  
  9. </EditText>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
kbkbkb
Freshman
Freshman
 
Posts: 6
Joined: Tue Jan 22, 2008 2:17 pm

Postby Ishtar » Tue Jan 22, 2008 6:24 pm

Didn't test, but this should do the job.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myEditText.setSelection(0,myEditText.getText().length());
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Ishtar
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Wed Jan 16, 2008 10:22 pm
Location: Netherlands

Postby ramgraph1 » Tue Jan 22, 2008 10:48 pm

Thanks for your responses. The java code from Ishtar was just what I needed.
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Postby ramgraph1 » Fri Feb 15, 2008 3:37 pm

Since upgrading to the new SDK (it is hard to say it feels like an upgrade at this point), this code I got help with and had been using to good effect seems to have stopped working though setSelection doesn't appear on the API Diff page. Does anyone know anything about this?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myEditText.setSelection(0,myEditText.getText().length());
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Postby plusminus » Fri Feb 15, 2008 4:36 pm

Hello ramgraph1,

the code has to be right := this is obviously not our fault.
ramgraph1 wrote:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myEditText.setSelection(0,myEditText.getText().length());
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


ramgraph1 wrote:... (it is hard to say it feels like an upgrade at this point)...

I'm also a """bit""" frustrated. But we have to deal with that, jumping in at a Pre-Alpha SDK :cry:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 21 guests