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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:13:19+00:00 2026-06-12T02:13:19+00:00

I have an AutoCompleteTextView where the user is to write in a single-line search,

  • 0

I have an AutoCompleteTextView where the user is to write in a single-line search, i.e. no line breaks are allowed. Using android:singleLine="true" allows this to work properly.

However, I also wish to set a hint to display when no other text has been entered, and this text does require more than one line. My problem is that with Android 4+, the hint is not wrapped to several lines. With Android 2.3, however, the content does get wrapped and multiple lines are displayed. Users are still not able enter more than one line, so this is the way I want it.

Using for example android:maxLines="2" does not help since that allows the user to insert a line break when searching. I’ve also tried android:scrollHorizontally="false" and android:ellipsize="none" and android:layout_weight=1 without success.

Any ideas on how I can get the hint to wrap multiple lines and still only accept a single line from users with Android 4 as well? Below is the code I’m using at the moment.

    <AutoCompleteTextView
        android:id="@+id/autoCompleteTextView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:completionThreshold="3"
        android:hint="This is the hint to be displayed. It's rather long and doesn't fit in one line"
        android:singleLine="true" />
  • 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-12T02:13:20+00:00Added an answer on June 12, 2026 at 2:13 am

    Try changing singleLine to:

    android:lines="1"
    

    And now to disable “Enter”:

    EDIT_TEXT.setOnKeyListener(new OnKeyListener()
    {

            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event)
            {
                if (keyCode == KeyEvent.KEYCODE_ENTER)
                {
                    return true;
                }
                return false;
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know if this is possible using Android's XML: I have AutoCompleteTextView
I'm making my own search view for Android 2.3. I have. LinearLayout (Horizontal) AutoCompleteTextView
I have a AutoCompleteTextView which gives user auto-completion search result from Google Places API
I have an AutoCompleteTextView which is using an ArrayAdapter<android.location.Address> as its Adapter . The
I have this layout, <TableLayout android:stretchColumns=0 android:layout_width=fill_parent android:layout_height=wrap_content> <TableRow> <AutoCompleteTextView android:id=@+id/StationTextView android:layout_width=fill_parent android:layout_height=wrap_content android:completionThreshold=2
I have an ArrayAdapter (myAdapter) attached to an AutoCompleteTextView (textView) component. Once the user
On this tutorial on the android devs about AutoCompleteTextView. Would I need to create
Does anyone know if it's possible to have the adapter for an AutoCompleteTextView search
I am developing an android application. I have an autocompleteTextView in my layout. I
I want to use AutoCompleteTextview for a list I have. I am using also

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.