Can someone tell me how can I show suggestions on a "Multiline" MultiAutoCompleteTextView. I went to the API reference Here.
I tried that example and the Autocomplete worked just fine except when i go to the next line I do not see the suggestions any more.
I have an xml that definees my MultiAutoCompleteTextView like so:
<?xml version="1.0" encoding="utf-8"?>
<MultiAutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/html"
android:focusable="true"
android:gravity="top"
android:background="#null"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:singleLine="false"
android:completionThreshold="1"
android:textSize="14dp"
android:scrollHorizontally="true"
android:focusableInTouchMode="true" />
My code that does the suggestions is like so: (Got it from the reference)
MultiAutoCompleteTextView editor = (MultiAutoCompleteTextView) LayoutInflater.from(getApplicationContext()).inflate(R.layout.editor, null);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
editor.setAdapter(adapter);
editor.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
Since I set the singleLine to false on my MultiAutoCompleteTextView xml. The suggestions do not show when I press enter to go to the next line.
Can anyone help me on this. Is there a way i can override the suggestions panel to my liking? Also is there a way to position the panel?
android:inputType="textMultiLine"
"Normal text keyboard that allow users to input long strings of text that include line breaks (carriage returns)."
http://developer.android.com/guide/topics/ui/controls/text.html
Related
The following spinner is still clickable to show the list:
<Spinner
android:id="#+id/spinnerFoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="15dp"
android:gravity="center"
android:clickable="false"/>
Could anyone shed some light on this?
I know from my reading that one can disable a spinner by doing it in Java code (spinnerFoo.setEnabled(false). My question is about doing it in XML.
[EDIT]
The following is all the Java code using the spinner:
ArrayAdapter<Integer> adapterFoo = new ArrayAdapter<Integer>(this, R.layout.spinner_item, aiFoo);
spinnerFoo = (Spinner) findViewById(R.id.spinnerFoo );
spinnerFoo .setAdapter(adapterFoo );
spinnerFoo .setSelection(1);
Clickable is not going to stop the spinner from opening because it does not depend on click event.You have to use android:enabled="false"
EDIT
You can set this in the Java code itself, instead of in the XML, because the Spinner should implement setEnabled(boolean) from View
Add this android:enabled="false"
Write this in your xml
android:enabled="false"
I have a ListPopupWindow defined as below in my Android application.
ListPopupWindow listPopupWindow;
listPopupWindow = new ListPopupWindow(RootView.this);
listPopupWindow.setAdapter(new ArrayAdapter<String>(RootView.this,
R.layout.push_list_item, pushMessages));
listPopupWindow.setAnchorView(bEvents);
listPopupWindow.setWidth(300);
listPopupWindow.setHeight(400);
listPopupWindow.setModal(true);
listPopupWindow.show();
The XML for the layout referenced above is given below..
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF0000"
android:paddingLeft="6dp"
android:textSize="12sp"
android:maxLines="3"
android:lines="3"
android:ellipsize="end"
android:textStyle="bold" />
When I get a text that is larger in size, the text just seems to clip as opposed to wrap, even though I have specified the correct attributes inside the XML. Can anyone help me understand what is going on here, and propose a solution for my problem.
Thanks..
The main problem you should get with your xml file that it's not possible to have >2 lines + ellipsize.
You should implement you own EllipsizeTextView to support real multiline ellipsized textview.
You could find an example here and here.
Also you could find this bug here.
If I enter a word "wood" in AutoCompleteTextView , then result comes in drop down list :
"bolly wood "
"holly wood "
"wood"
I want result like this:
"wood"
"bolly wood"
"holly wood"
AutoCompleteTextView does alphabatical sorting.How to stop this sorting???
Did your tried this:
In the layout XML, add the following attribute to your EditText:
android:inputType="text|textNoSuggestions"
If neither this, nor the above approaches work, then this is almost certainly a problem with the emulator and the other device, and you should contact the manufacturers directly.
See also: android:inputType (note that EditText is a subclass of TextView, which is why this attribute also works for EditTexts).
Use android:completionThreshold="1"
to show list of option while entering a single character('w')..
So possible outcome is like
**"wood"
"bolly wood"
"holly wood"**
<AutoCompleteTextView
android:id="#+id/autocomplete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:paddingLeft="10dp"
android:completionThreshold="1"
android:textSize="18sp"
/>
I have a Spinner which displays single digit numbers (1-6).
When I test on a phone, it's virtually impossible to click on a number because they are so narrow (font size is 12sp) and the only area which appears to be clickable is the text itself.
Ideally I'd like the user to be able click on a greater width on the Spinner drop down than just the text. I've tried padding with spaces but these are suppressed, and I've tried using PaddingLeft/Right but again there's no difference.
Here is the Spinner
<Spinner
android:id="#+id/spinner_period1"
android:layout_toRightOf="#id/spinner_weekday1"
android:layout_below="#id/col1day"
android:layout_height="wrap_content"
android:prompt="#string/enterperiod"
android:layout_width="80dp"
android:entries="#array/periodlist"
android:layout_marginRight="340dp"
android:layout_marginBottom="20dip"
/>
Note that I also set the Spinner text attributes using:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="12sp"
android:textColor="#768766"
/>
Any ideas? Thanks in advance
Mark
Try making the TextView wider in the android:layout_width attribute.
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textview"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textSize="12sp"
android:textColor="#768766"
/>
That could possibly fix your issue or make it better at least.
Try setting your TextView layout width to some arbitrary value rather than "wrap_content". That should make the whole thing clickable, as opposed to just the wrapped content.
Just adding some padding to the spinner helped me fix this issue.
<Spinner
android:id="#+id/spinner"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:padding="25dp"
android:scrollbarSize="20dp" />
Way 1:
Display the spinner's options as a dropdown by using android:spinnerMode. Therefore have a look at the API (Android API Spinner). Or play around with android:dropDownWidth.
Way 2 (I used it in an APP but at the moment I have no access to the code):
Maybe you could set another layout while populating your spinner with text - instead of assigning the values in the XML.
Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.planets_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
It's copied from the following link Android Spinner. Maybe you could use one of the layout templates of android.R .
Whenever a word is typed in the EditText box, I always see an underline under the word being typed. But when I press a space after that word I no longer see the underline.
My reqirement is to remove that underline when the user is typing the message.
Added is the screenshot and we see that Smith is underlined. But I don't want this to happen.
Below is the xml that I use for the AlertDialog box.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/name_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="#string/alert_dialog_name"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/username_edit"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:inputType="textPersonName"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
android:inputType="textNoSuggestions"
There is a function that removes any composing state. I think if you call it after every time a user types, you will not see the underline. I use it after the user finishes typing, to get the drawing cache of the entire textView (which I need without underline). It's
someTextView.clearComposingText();
You don't have to use any logic to remove the underlines -- just call getText().toString() when you want to use the value. It won't include special formatting or anything.
accepted answer is not given solution, and some other user given answer but no one given full anser, so that's why i write here working solution.
If you want to remove underline then just add below code.
XML
android:inputType="textNoSuggestions"
Java
EditText ed;
ed = findViewById(yourId);
ed.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
If you want to set more than one input type then,
ed.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
May be above information is helpful to others.
The best solution for this is to add on your EditText:
android:inputType="textMultiLine|textVisiblePassword"
Use this from your class, if EditText view is dynamic (created from class file):
EditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
OR include android:inputType="textNoSuggestions" with your EditText in XML.
Read this if you want to keep emojis and textNoSuggestions doesn't work for you.
textNoSuggestions does not work in every keyboard.
inputType="textVisiblePassword" works but it removes emoji's from most keyboards.
I found that setting inputType="textUri" works and keeps the ability to add emojis.
try:
android:inputType= InputTypes.TextVariationVisiblePassword;
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:imeOptions="actionDone"
android:inputType="textNoSuggestions"
android:maxLines="1"
/>