Android: ListView causing requestLayout() to be improperly called - android

Having fast scroll enabled in my ListView is causing the following error:
08-09 01:47:33.294 10816-10816/com.exampleW/View﹕ requestLayout() improperly called by android.widget.TextView{...} during layout: running second layout pass
I know the ListView is causing the problem because removing the following line of code from the ListView's XML removes the error:
android:fastScrollEnabled="true"
Is there any way to fix this error? To be thorough, I have also included the TextView's XML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

i think this error is not because of android:fastScrollEnabled="true" however try below code in your java file..
try list.smoothScrollToPosition(0); also with android:fastScrollEnabled="true"
so that data appears when scroll is called...
something like this..
new Handler().postDelayed(new Runnable()
{
#Override
public void run()
{
list.smoothScrollToPosition(0);
}
}, 100);

this is known bug in android implementation when you set fastScrollEnabled = true, which appears in some android versions.
https://code.google.com/p/android/issues/detail?id=75516
Apart from the ugly console spamming with the debug message from above, there seem to be no other impacts (maybe performance in some cases, which I haven't tested).

Related

Error message text for TextInputLayout is cut off

Hey anyone know why this (see in the picture) happens?
It's happens for Xiaomi MiA1, while on Nokia 7.1 works fine.
My xml view layout
FrameLayout - root
ScrollView
RelativeLayout
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/profile.EMAIL"
android:theme="#style/TextInputLayoutTheme"
android:margin="16dp"
android:paddingBottom="8dp"
app:layout_constraintTop_toBottomOf="#+id/phone_wrapper"
>
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:textSize="16sp"
android:textColor="#color/darkTextColor"
android:imeOptions="actionDone"
tools:text="Email"
/>
</com.google.android.material.textfield.TextInputLayout>
I think that putting TextInputLayoutTheme is not relevant here, since I only manipulate with view's colors
The error message text gets cut off if you are setting the error on a TextInputLayout more than once.
So every time you are setting TextInputLayout error message text, just set it to null first.
textInputLayout.setError(null);
textInputLayout.setErrorEnabled(false);
textInputLayout.setError("Error Message");
Layout Inspector shows that even if there is some space for the error it doesn't draw view in all of it. Everything there is in LinearLayouts (and one simple FrameLayout) so there is no way something would overlap it, paddings are set to 0, there is no code changing height or something suspicious in the implementation, so I don't know what might be a reason of such behaviour.
Although I've found some solution which works. You need to find in TextInputLayout a view holding error (with id textinput_error) and add some small padding to it. I've done it by extending TextInputLayout and adding such code into init.
val errorTV = findViewById<TextView>(R.id.textinput_error)
errorTV.updatePadding(top = 4)
There is already issue on issue tracker - https://issuetracker.google.com/issues/116747167 so lets hope Google will fix it some day.
I resolved issue by saving and restore LayoutParams:
final ViewGroup.LayoutParams params = textInputLayout.getLayoutParams();
textInputLayout.setError(errorMessage);
textInputLayout.setLayoutParams(params);
I resolved issue by increasing size of error font to 14sp (orginal is 12sp)
<com.google.android.material.textfield.TextInputLayout
[...]
app:errorTextAppearance="#style/MyProfile.Error">
<style name="MyProfile.Error" parent="TextAppearance.Design.Error">
<item name="android:textSize">14sp</item>
</style>
Although as Shabbir Dhangot said I may be that setting TIL.setErrorEnabled(true) may help for some else.
As some have already pointed out, this is a known bug. See https://issuetracker.google.com/issues/116747167
I solved this by doing something like this (note that below code is Kotlin, so != works on Strings):
if(myInputLayout.error != error){
myInputLayout.error = error
}
I know it is not the best solution, but you can add a \n to the beginning of your error message.
For example, if your error is Error, just change it to \nError.
If you want to change the size of the \n you can use:
String newLine = "\n";
String errorMessage = "Error";
SpannableString spannableErrorMessage = new SpannableString(newLine + errorMessage );
spannableName.setSpan(new TextAppearanceSpan(activity, R.style.my_style),0,a.length(), 0);
spannableName.setSpan(new RelativeSizeSpan(2.0f), a.length(), a.length() + 1, 0);
You can use this Kotlin extension:
/**
* Fix a bug with [TextInputLayout] that cut the error text when setting the same text twice.
*/
fun TextInputLayout.setFixedError(errorTxt: CharSequence?) {
if (error != errorTxt) {
error = errorTxt
}
}
Usage:
yourTextInput.setFixedError("Your error text")

setVisibility(View.GONE) causes a Crash

[Edit: I have just replaced adView.setVisibility(View.GONE) with adView.setVisibility(View.INVISIBLE) the WebView loads and nothing crashes, so it really looks like it is something to do with when I remove the AdView xml element, rather than just making it invisible. Making it invisible is not ideal, as you get a white empty bar at the bottom where the Ad should have been. So it really looks like it is something to do with reloading the Webview or messing with the UI. My html/javascript code is solid and can handle any dimension changes.]
I have a Webview above a banner for an advert (the "ca-app-pub-3940256099942544/6300978111" is the test ad id, so I am not given out any personal info)
<WebView
android:id="#+id/webView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="#+id/adView" />
<!-- "BANNER" or "LARGE_BANNER" -->
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-3940256099942544/6300978111"/>
Note: the app:layout_constrain... in the Webview. I think that might be part of the problem.
At start up, I am checking for purchases. If the user has made any purchases whatsoever, I turn off the ads with the code:
public void turnAdvertsOff() {
advertsOn = false;
AdView adView = (AdView) m_Context.findViewById(R.id.adView);
adView.destroy();
adView.setVisibility(View.GONE);
}
With the line adView.setVisibility(View.GONE); the program crashes with the unfounded allegation:
I/chromium: [INFO:CONSOLE(6381)] "Uncaught Error: Java exception was raised during method invocation", source: file:///android_asset/www/index.html?IsAndroidWebview=true (6381)
D/WebView: loadUrl=about:blank
D/WebView: destroy
However, I know there is nothing wrong in the Webview, as when I hash out the line //adView.setVisibility(View.GONE);, the WebView loads fine.
Does anyone know why?
Is it anything to do with the app:layout_constraint.., and if so how do I overcome it?
This is what is recommended to hide the adView:
adView.pause();
adView.setVisibility(View.GONE);
Try using a LinearLayout as below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<WebView
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_weight="1" />
<!-- "BANNER" or "LARGE_BANNER" -->
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adSize="BANNER"
android:layout_gravity="center"
app:adUnitId="ca-app-pub-3940256099942544/6300978111" />
</LinearLayout>
SMART_BANNER
OK, I have found the answer, and it is not obvious. It is a combination of #mTak 's answer and a critical bit of how Android apps work (which is something I did not realise since I come from an html/javascript world and multi-threading is something programmers have absolute control over in that environment).
The purchases checks were being made on another thread. So the attempt at doing adView.setVisibility(View.GONE) was causing grief to the program. It does not seem to like you messing with the UI except on the main UI thread.
So this is how I changed my code to make the Android protocols happy:
My Purchase check (in a separate thread, but in the MainActivity). Note, stringListARR is just an array of strings with the product codes that the user had purchased. So if there was at least one purchase, whatever it was, I had decided to turn off adverts:
// Any purchase means we have no adverts
myAdverts.advertsOn = stringListARR.size() > 0 ? false : true;
// This is the evil line of code that caused the problem - this was being called not on the UI thread
//if(!myAdverts.advertsOn) myAdverts.turnAdvertsOff();
// And this is how to do it properly forcing it to be run on the UI thread
// 'this' in the following is my MainActivity
if(!myAdverts.advertsOn){
this.runOnUiThread(new Runnable(){
#Override
public void run() {
myAdverts.turnAdvertsOff();
}
});
}
And #mTak was perfectly right how to do things properly. My turnAdvertsOff() looks like this:
public void turnAdvertsOff() {
advertsOn = false;
AdView adView = (AdView) m_Context.findViewById(R.id.adView);
adView.pause();
adView.setEnabled(false);
adView.setVisibility(View.GONE);
}
So thanks to #mTak and thanks to this almost unfindable thread on google which gave me the idea:
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/d30EAC1zGFo
In fact, if any people here on Stackoverflow are answering questions about crashes when people are messing with the UI in Android, this runOnUiThread might be the first solution that springs to mind. It is not obvious and a pain to discover.

In Android: How to Force refresh (update) of a TextView that is INSIDE a Dialog Window?

This is probably a basic procedure, and in fact I've been extensively searching for a suitable answer, but I haven't found anything usable or that actually works. Now, the case:
A Dialog window is placed inside a method:
public void method_with_Dialog_code() {
Dialog simpleDialog = new Dialog(this, R.style.FilterDialogTheme);
simpleDialog.setContentView(R.layout.dialog_xml_layout);
simpleDialog.setCancelable(true);
TextView insideTextView = (TextView) simpleDialog.findViewById( R.id.insidetextview );
insideTextView.setText("This text should change when the WiFi is offline");
simpleDialog.show();
}
The respective dialog_xml_layout.xml file is simply:
<?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="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/insidetextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
If the device is for example disconnected from the Internet, it generates a message that should be shown in the insideTextView. But notice that simpleDialog and insideTextView are inside the method, so they are local objects, so the first issue is how to execute:
insideTextView.setText("This device is now offline");
from another part of the code, that is, outside of the method?
If I decide to make simpleDialog and insideTextView as Global variables, I can with no problem, from another part of the program, set the line:
insideTextView.setText("This device is now offline");
But the instruction doesn't work. The TextView is never updated with the new message.
So, any ideas? Maybe with TextView.addTextChangedListener, so insideTextView could be updated when the TextView.setText is executed externally?
Gracias.
make insideTextView a member variable of the class and use it later.

Android: requestLayout() improperly called

The following error occurs when I attempt to inflate a layout within a ListView:
requestLayout() improperly called by android.widget.TextView{...} during layout: running second layout pass
I am attempting to inflate a layout within a ListView as follows:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
LayoutInflater inflater = (LayoutInflater) musicActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_item, parent, false);
...
}else{...}
}
The layout being inflated can look as simple as the following, and will still produce the error
<TextView
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/txt_size"/>
I have looked into similar questions, and no solutions found seem to work Question 1, Question 2, Question 3.
Does anyone know what causes this type of error? Any troubleshooting advice? For more context, this ListView is displayed within a Fragment within a ViewPager
UPDATE
Here is the full XML Layout (minus a bunch of attributes), that still results in the problem
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txt4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
Based on this, I would think the XML itself is not a problem, unless it has to do with the fact that I am using a ViewPager and Fragments
This issue seems to be a bug in the android implementation, please see: https://code.google.com/p/android/issues/detail?id=75516
Activating the fast scroll feature of a ListView in your code via ListView.setFastScrollEnabled(true) will trigger this bug and you'll start seeing the
requestLayout() improperly called by android.widget.TextView{...}
during layout: running second layout pass
message in your console.
This bug must have been introduced in one of the KitKat (4.4.x) updates, as I've not seen it with the initial KitKat (4.4.0) release. Apart from the ugly console spamming with the debug message from above, there seem to be no other impacts (maybe performance in some cases, which I haven't tested).
Cheers
PS: it's not the first time that the fast scroll feature is bugged, e.g. https://code.google.com/p/android/issues/detail?id=63545, 63545 was fixed in KitKat 4.4.3 but 75516 poped up thereafter --> seems to be a vexed subject for google ;-)
EDIT May 12 2015:
I updated my Nexus 7 to Android 5.1 some minutes ago (was Running 5.0 before) and stopped seeing this issue in this new version. As the appearance of the FastScroll indicator also changed in 5.1, I assume that google fixed this issue or at least commented out those ugly lines that spammed the console...
75516 & 82461 are still 'unresolved', but I guess that those refer to the same issue, that's now resolved in 5.1.
The problem is that while the method getView() of your adapter is displaying your layout some other code is trying to access this view to display it, resulting in a collision.
Note that some methods, that maybe you don't take care of (like setScale(), setTypeFace()) indeed call requestLayout(), so it would be interesting what you are doing after your inflate statement.
For me this issue was occurring upon a setLayoutParams() call. The solution was posting a runnable on the looper:
// java
imageView.post(new Runnable() {
#Override public void run() {
imageView.setLayoutParams(params);
}
});
// kotlin
post(Runnable { imageView.setLayoutParams(params) })
I fixed this issue by disabling fastScroll on the ListView in the XML.
<ListView
android:id="#+id/mListview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fastScrollEnabled="false"
/>
In my case (Samsung Galaxy S4, API 21) this happened in ListView with EditTexts. I have a listener for field validation. Something like:
edit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
error.setVisibility(View.INVISIBLE);
error.setText("");
} else {
String s = edit.getText().toString();
if (s.isEmpty()) {
error.setText("Error 1");
} else if (s.length() < 2 || s.length() > 100) {
error.setText("Error 2");
}
error.setVisibility(View.VISIBLE);
}
}
});
After settinging focus in one of these EditTexts an above check is called. After that a TextView will change (the TextView contains an error message and lies over the EditText).
Setting focus to the second or the third EditText led to permanent request of the first EditText and return to current. An applications runs in infinite loop of requests (focus edittext 1, unfocus edittext 1, focus 3, unfocus 3, focus 1, etc).
I tried to set listView.setFastScrollEnabled(false). Also I tried a requestLayout() of some elements like in https://github.com/sephiroth74/HorizontalVariableListView/issues/93 with no chances.
Currently I made that TextView of fixed width and height in XML:
<TextView
android:id="#+id/error"
android:layout_width="match_parent" (or "200dp", but not "wrap_content")
android:layout_height="20dp"
.../>
After some experiments I noticed that a height of 20dp can be replaced with "wrap_content". But if a text is too long that divides into 2 lines, the application again catches in the infinite loop. So, android:singleLine="true" will help. It is deprecated, but amazingly android:maxLines="1" with android:lines="1" don't help as they again request layout.
Eventually we have:
<TextView
android:id="#+id/error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#f00"
android:textSize="20sp"
tools:text="Error message"/>
That's not a good solution, but at least it breaks the infinite loop.
This might happen if you are using some 3rd party extension of ListView. Replace that with standard ListView and check if it still throws the error.
I had similar problem. Please check Android layout: running second layout pass and my answer.
I had the same issue with Kitkat 4.4.4 on Motorola X with Genymotion. In my case the list item is a simple CheckedTextView and the error occurred in AppCompatCheckedTextView.
As a normal implementation I inflated the item from XML layout file like below:
if (convertView == null) {
convertView = inflater.inflate(R.layout.checkable_list_entry, parent, false);
}
After some trying I found out that this has something to do with XML inflation. I don't know the root cause, but as a solution I decided to inflate the list item by code and set all the properties by code too.
It ended up like this:
CheckedTextView view;
if (convertView == null) {
view = new CheckedTextView(parent.getContext());
view.setMinHeight(getResources().getDimensionPixelSize(R.dimen.default_touch_height));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
view.setTextAppearance(R.style.SectionEntry);
} else {
view.setTextAppearance(parent.getContext(), R.style.SectionEntry);
}
view.setBackgroundResource(R.drawable.form_element);
view.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
view.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
} else {
view = (CheckedTextView) convertView;
}
I had a problem with the same warning log :
requestLayout() improperly called by android.support.v7.widget.AppCompatTextView {...} during layout: running second layout pass
I was working with recylcerview and going to update it with new data.
The only solution that worked for me is as below :
Step(1). Remove current data :
public void removeAll() {
items.clear(); //clear list
notifyDataSetChanged();
}
Step(2). When you want to populate the recyclerview with new data, first set a new LayoutManager to recyclerview again:
private void initRecycleView() {
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false));
}
Step(3). Update the recyclerview with new data. for example :
public void refreshData(List newItems) {
this.items = newItems;
notifyItemRangeChanged(0, items.size());
}
Try taking off the textSize from the xml and setting it in Java code. I think that's causing it to be laid out twice.
In my case this warning prevented a button from showing up in API 21 devices. The button visibility was previously set to GONE.
The only workaround I got it was setting to INVISIBLE instead of GONE for API 21. It wasn't a real solution but it was acceptable for me.
I only post this because it can be useful from somebody.
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
theButton.setVisibility(View.INVISIBLE);
}
else {
theButton.setVisibility(View.GONE);
}
Sometimes you maybe already fixed the issue but it still keeps same error, so you need to close visual studio then delete all bin and obj folders from your projects, then uninstall the app from the emulator. then walah!! everything will works fine
I solved the problem like this:
mHolder.txt_fword.setTextSize(22);
mHolder.txt_farth.setTextSize(22);
mHolder.txt_fdef.setTextSize(22);
mHolder.txt_fdef2.setTextSize(22);
mHolder.txt_frem.setTextSize(22);
//if (fdef2.get(pos).equals("")) mHolder.txt_fdef2.setVisibility(View.GONE);
//if (frem.get(pos).equals("")) mHolder.txt_frem.setVisibility(View.GONE);
issue is .setVisibility(View.GONE); , change to .setVisibility(View.VISIBLE);

Span error when sending email from android device within the app [duplicate]

I have the following layout (virtually empty):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/set_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="content desc"
android:orientation="vertical" >
<TextView android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
</LinearLayout>
The Activity class contains the following:
public class TestActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
}
}
When I run this on my mobile device I get the following error:
SpannableStringBuilder
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
I have tried this with and without the TextView and the error still remains, I must be doing something fundamentally wrong for such a basic layout to cause this.
Does anyone have any ideas on how I can get this to load without the error?
I have run into the same error entries in LogCat. In my case it's caused by the 3rd party keyboard I am using. When I change it back to Android keyboard, the error entry does not show up any more.
Because the error you're getting is not related to an EditText, then it's not related to your keyboard.
The errors you are getting are not a result of your code; you probably are testing on a Samsung device that has Samsung's TouchWiz.
I had the same errors, then I tested on a Nexus S (also by Samsung, but pure Android OS without TouchWiz) and I didn't get this error.
So, in your case, just ignore these errors while testing on a device! :)
Looking at your code, I'm not sure why you're getting that error, but I had this same error but with EditText fields.
Changing android:inputType="text" (or any of the other inputType text variations) to android:inputType="textNoSuggestions" (or android:inputType="textEmailAddress|textNoSuggestions", for example) fixed it for me.
You can also set this in Code with something like
mInputField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Looks like Android assumes by default that EditText fields will have suggestions. When they don't, it errors. Not 100% confident in that explanation, but the above mentioned changes fixed it for me.
http://developer.android.com/reference/android/text/Spanned.html#SPAN_EXCLUSIVE_EXCLUSIVE
Hope this helps!
On your android phone go to:
settings -> application manager -> all -> samsung keyboard and then click on "clear cache"
(delete all data collected by this application).
Try using the default Android keyboard it will disappear
Make clear you have pass a value in your MainAcitivity for the following methods onCreateOptionsMenu and onCreate
In some cases, the developer deletes the "return super.onCreateOptionsMenu(menu)" statement and changed to "return true".
This worked for me...on every device
<EditText
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15sp"
android:layout_centerVertical="true"
android:textColor="#000"
android:id="#+id/input_search"
android:background="#null"
android:inputType="text"
android:hint="Enter Address, City or Zip Code"
android:imeOptions="actionSearch"
/>
In Java code:
mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
#Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
if(actionId == EditorInfo.IME_ACTION_SEARCH
|| actionId == EditorInfo.IME_ACTION_DONE
|| keyEvent.getAction() == KeyEvent.ACTION_DOWN
|| keyEvent.getAction() == KeyEvent.KEYCODE_ENTER){
//execute our method for searching
}
return false;
}
});
I had the same warning and found that removing an unused #id got rid of the warning. For me it was obvious as the #id was associated with a growing list of textViews linked to a database, so there was a warning for each entry.
Masood Moshref is right, this error occur because the option menu of Menu is not well prepared by lacking "return super.onCreateOptionsMenu(menu)" in onCreate() method.
To try to debug this error, first go to your android terminal / console and execute this command:
ps | grep THE_ERROR_PID_YOU_GET_(IT_IS_A_NUMBER)
then if the output comes out as your app... it is your app causing the error. Try to look for empty Strings that you pass into the layout.
I had this exact same problem and it was my fault as I was passing an empty String into my layout. After changing the "" to " " this error went away.
If you don't get your app from the console output, then it is something else causing it (probably, as others said, the android keyboard)
I have faced the same issue. I almost wasted almost couple of weeks to resolved this issue.
Finally I had on doubt on myself and tried to create another project by copy and paste some startup files like SplashScreen & LoginScreen.
But with the same code still i was getting SPAN_EXCLUSIVE_EXCLUSIVE.
Then i have removed the handler code from splash screen and tried again and Wow its working.
I am not getting SPAN_EXCLUSIVE_EXCLUSIVE issue in logcat.
I wondering, why it is? till the time did not get any other solution but by removing handler from splash screen it is working.
Try and update here if it is resolved or not.
Check if you have any element such as button or text view duplicated (copied twice) in the screen where this encounters. I did this unnoticed and had to face the same issue.
I ran into this problem too when I copied some text from the Internet. My solution is to trim the text/remove formatting before doing any further processing.
I had the same problem but with a listView.... i solved it because i was using a wrong R.id.listView that list View needed to have a value, in my case it was strings that i saved on listView2... so the right code was R.id.listView2
I had the same problem then i fixed it by following code!
text = (EditText)findViewById(R.id.TextVoiceeditText);
text.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
this error also occurs due to changed API URL. try hitting the URL you are using in postman and c if it's working properly.
rechecking the APIs solved my problem
try avoiding use of view in xml design.I too had the same probem but when I removed the view. its worked perfectly.
like example:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:inputType="number"
android:textColor="#fff" />
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#f9d7db" />
also check and try changing by trial and error android:inputType="number" to android:inputType="text" or better not using it if not required .Sometimes keyboard stuck and gets error in some of the devices.
In my case, the EditText fields with inputType as text / textCapCharacters were casing this error. I noticed this in my logcat whenever I used backspace to completely remove the text typed in any of these fields.
The solution which worked for me was to change the inputType of those fields to textNoSuggestions as this was the most suited type and didn't give me any unwanted errors anymore.
in my case i click on recent apps shortcut on my cell phone and close all apps. This solution always work for me, because this error not related to code.
**DONT PUT SET TEXT IN TEXT WATCHER**etSearch.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable) {
visibleResultList = false
if (s.toString().length != 0) {
getSearchSuggetion(no_of_rec, 0, s.toString())
} else {
// etSearch.setText("")
}
Log.e("text_change","============"+s.toString())
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
}
})
To solve this problem just add android:usesCleartextTraffic="true" in your AndroidManifest.xml file which is at ..\app\src\main\AndroidManifest.xml just like bellow...

Categories

Resources