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 9116655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:43:37+00:00 2026-06-17T04:43:37+00:00

I am having problem with limiting edittext length in android. Everything works perfect except

  • 0

I am having problem with limiting edittext length in android. Everything works perfect except when delete message.
My edit text control has max length of 16 characters and it will limit it for recognizing, displaying and reading first 16 characters but when I continue to type, it memorizes text somewhere in background and if I want to delete text it doesn’t start to delete backwards from 16th character but from last one I have entered.
See below code.

I have even tried to add TextChangedListener it doesn’t trigger 16 character is entered as there isn’t any action.

I am using Nexus 7 for testing this functionality

LAYOUT

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="@drawable/background"
    android:orientation="vertical"
    android:padding="10dp" >


    <TextView
        android:id="@+id/send_new_message_lblTo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="@string/send_new_message_to"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/send_new_message_lblToValue"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@+id/send_new_message_lblTo"
        android:ems="10"
        android:textAppearance="?android:attr/textAppearanceLarge" >
    </TextView>

    <EditText
        android:id="@+id/send_new_message_txtMessage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/send_new_message_lblToValue"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:hint="@string/send_new_message_hint"
        android:inputType="textMultiLine"
        android:lines="2"
        android:maxLength="16"
        android:scrollbarStyle="outsideOverlay" />

    <Button
        android:id="@+id/send_new_message_btnSend"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/send_new_message_txtMessage"
        android:layout_marginTop="10dp"
        android:text="@string/send" />

</RelativeLayout>

ACTIVITY

  import android.os.Bundle;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;

    public class NewMessageSendActivity{

    private TextView to;
    private EditText message;
    private Button send;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.send_message);
        getViewInstances();
        setControlActions();

    }

    private void getViewInstances() {
        to = (TextView) findViewById(R.id.send_new_message_lblToValue);
        message = (EditText) findViewById(R.id.send_new_message_txtMessage);
        send = (Button) findViewById(R.id.send_new_message_btnSend);

        to.setText(AppSettings.getInstance().getSelectedDevice().toString());
    }

    private void setControlActions() {

        send.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                String smsMessage = message.getText().toString();
                Toast.makeText(this, smsMessage, Toast.LENGTH_SHORT).show();
            }
        });
    }
}

  • 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-06-17T04:43:39+00:00Added an answer on June 17, 2026 at 4:43 am

    I cannot reproduce your behavior. It seems everything is ok, and the text is correctly limited to 16 characters.

    The only place where the keyboard keeps appending text, is in the field above it, but even when you select the suggested word, it is truncated before being inserted in the text field. That’s why you don’t see the event fired, because it’s an internal event in the IME, not an Android one inside the EditText.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im having problem whith a POST request. I have to receive an XML message
I am having a problem limiting my query results to a related table value.
Iam having problem creating postgresql function in plperl CREATE OR REPLACE FUNCTION zm_json (TEXT,
I am having problem of showing Toast Message when i click a button within
I am having problem with Jquery tabs UI. <script type=text/javascript> $(document).ready(function() { $('.tabs').tabs(); $('.subtabs').tabs();
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working
I am having problem with previewing custom performance counters with PerflibV2. Performance Monitor shows
I am having problem to get a numerical value for this expression where I

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.