Set multiline text for EditText HINT

I know that I could change the number of lines for EditeText text, but can I change it in the EditText tooltip too?

I could not find a solution on the Internet.

Thanks for the help.

My code is:

@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.property_search, menu); super.onCreateOptionsMenu(menu, inflater); final MenuItem searchViewMenuItem = menu.findItem(R.id.action_search); mSearchView = (SearchView) searchViewMenuItem.getActionView(); int searchSrcTextId = getResources().getIdentifier("android:id/search_src_text", null, null); EditText searchEditText = (EditText) mSearchView.findViewById(searchSrcTextId); searchEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); searchEditText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); searchEditText.setHint(getString(R.string.search_hint)); } 

strings.xml

 <string name="search_hint">keyword, location, \nmax price (eg 1K, 1M)</string> 

I want:

keyword, location,

maximum price (e.g. 1K, 1M)

+5
source share
4 answers

Nothing worked for me, but:

  <EditText android:id="@+id/text" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textMultiLine|textLongMessage" android:hint="\n"/> 

Honestly, I don’t understand why .. but including "\ n", since the hint in xml did the trick!

Now you can call setHint from Java code:

 searchEditText.setHint(getString(R.string.search_hint)); 

and remove \ n from strings.xml if you want to allow automatic text layout according to room

 <string name="search_hint">keyword, location, max price (eg 1K, 1M)</string> 
+6
source

use the new line separator \ n in the ur prompt.

as

 android:hint="first line of hint \n second line of hint so on.." 

in rows

 <string name="urhint">first line of hint \n second line of hint so on..</string> android:hint="@string/urhint" 

hope it works.

+3
source

Try the following:

String.xml

 <string name="hint">Hint first line \n Hint second line \n Hint third line</string> 

layout.xml

  <EditText android:id="@+id/emailText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/login_edittext_background" android:imeOptions="actionNext" android:inputType="textEmailAddress" android:hint="@string/hint"/> 
0
source

set below two lines in your editor in your xml file

 android:inputType="textMultiLine" android:lines="3" 

therefore, when displayed in the preview window, 3 multi-line windows are displayed

0
source

Source: https://habr.com/ru/post/1211581/


All Articles