Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7059929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:17:28+00:00 2026-05-28T04:17:28+00:00

How do I insert characters into the middle of an EditText field? I’m making

  • 0

How do I insert characters into the middle of an EditText field?
I’m making a calculator that can take a string expression like “3*(10^2-8)”. I’m using an EditText field to make the string using XML like so:

EditText

android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label"
android:text="@string/testString1"
android:background="@android:drawable/editbox_background"

and then in my activity I have, say:

entry = (EditText)findViewById(R.id.entry);
entry.setText("blablahblah");
entry.setSelection(3);

Now I have an EditText field with the cursor blinking after the third character in the string. How do I insert a character there, so it correctly says “blahblahblah”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:17:29+00:00Added an answer on May 28, 2026 at 4:17 am

    The method getText() of the EditText widget returns an object that implements the Editable interface. On this object you can call the insert() method to insert text at a certain position.

    I found this out by reading the documentation, but never used this myself. But for your needs, to insert a character at the selected position in the EditText, the following should work:

    Editable text = entry.getText();
    text.insert(entry.getSelectionStart(), "h");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me how to insert special characters into a MySQL database? I've
How can I insert ASCII special characters (e.g. with the ASCII value 0x01) into
How can I insert Arabic characters into a SQL Server database? I tried to
I am trying to insert string-values larger than 5500 characters into a MSSQL 2008
How to insert special characters like & and < into JSF components value attribute
I'm trying to insert a string that was received as an argument into a
how to insert special characters into a database(MySQL) like Registered symbol ( ® )
I'm new to Python and can't find a way to insert a string into
Is it possible to auto insert characters into an EditText as the user inputs
I'm trying to insert a comment character into a string something similar to this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.