I have an app, where some fragments only consist of ListViews. Some of my users with low-end devices experience a phenomenon, where a fragment simply can not display the data. When they enter the fragment I display a ProgressBar, and this ProgressBar seems to spin forever.
So I bought a low-end device and am facing the same problem. I get the data for the ListView with a network request to my backend API, but the answer is never returned. The only warning I see so far is
W/ResourceType﹕ Too many attribute references, stopped at: 0x01010034
I could not find much about this error in the web but it seems like this warning is logged here https://github.com/SciAps/android-frameworks-base/blob/c693209edc3696884c1fcd59790dda0b9811d017/libs/utils/ResourceTypes.cpp#L1573, but I don't understand what the Android code is doing there.
Anyone has a clue about what's going on here, what's the problem and how I can fix that?
BTW I use RoboSpice and Retrofit to do the network requests. The background service that is responsible for getting the data is stopped after this warning, that's why I never get back data.
EDIT As far as I can tell not seeing the data has nothing to do with the warning. Anyway, what does this warning mean and how can I prevent it?
I accidentally applied a style as a theme on a view, which resulted in this warning showing up. In the view's XML, by using style="#style/MyStyle" instead of android:theme="#style/MyStyle" I was able to stop the warnings.
Actually, the most upvoted answer by #Corclark was not entirely accurate in my case. I got the same warning, but didn't have the style="#style/MyStyle" set anywhere. I experimented a bit and found out it was actually this line that caused the warning for me:
android:theme="#style/My.Switch"
Then, I found this answer. Changing the style of My.Switch to
<style name="My.Switch" parent="">
<item name="android:background">#color/dark_grey</item>
<item name="colorAccent">#color/Unpluq</item>
</style>
resolved the warning for me. Hope it might still be helpful to some.
It happens when using ContextThemeWrapper for creating new ElementViews
TextView txtView= new TextView(new ContextThemeWrapper(context, R.style.styleName));
Related
I have this layout xml
does order matter?
I mean what will be the padding?
what would happen if the same attribute repeat twice? compilation error?
4,4,4,0
or 4,4,4,4
or non deterministic?
As for already existing attribute, you cant use the same attribute more than once in the same XML tag.
If you do try to use the same attribute twice you will get “duplicate attribute” XML error.
I'm sorry, I completely miss understood your question in my previous answer and made a mistake myself.
I'm not sure where you can find this in the android docs, but from my own experience you cannot provide the same attribute twice (this would lead to a compilation error).
To update my previous answer (I've edited this post to get rid of it, so I don't confuse or mislead any one), with the padding example I gave, padding overrides padding-top no matter what order you put them in.
Also I'm sorry for the slow response, I've been away for a few weeks and only just got back. I hope you found a better answer before I updated this post and I'll be quicker to clarify anything if you want me to.
I can set text by simply doing setText(R.string.value), for example. I receive no compile or runtime errors. I learned this by mistake, as I always use to set text by getting my string values from resources, such as setText(getResources().getString(R.string.value). What is the difference? Has Android evolved to where it no longer requires the getResources() method? Will older devices be compatible?
This has actually been possible forever if you look at the TextView documentation: https://developer.android.com/reference/android/widget/TextView.html#setText(int)
There are also some other setText(…) methods in there which you might check out.
I'm generally never using the resource id's directly to display the text because it's like your said not generally known and causes some distraction for people not used to it. But I don't think that there are any benefits/drawbacks from using either of these two.
At the moment, I'm stuck with a very annoying kind of "bug" I assume regarding all Pre-Lollipop Android versions. It appears that (support) fragments don't apply the activity's theme they're assigned to. To make my explanations a bit easier, have the following demonstration:
My app runs with a turquoise theme at first. Let's say, the user decided to change the turquoise theme to a red theme. He or she restarts the app and is greeted with the following:
(screenshot taken on an Android 4.4.2 tablet)
Terrible sight, isn't it? However, if I run the same app in an emulator with Android L the whole theme problem doesn't even seem to exist.
There's especially one thing which seems odd about the tablet screenshot. The fragment itself doesn't apply the theme but child components inside the fragment which get added lateron (like the view with the exclamation mark which is hosted by a ViewPager) take and apply the theme as if nothing happened.
I'm not quite sure what the issue might be. I've done everything as stated in every document available. I set the theme before I call setContentView(resource) in the corresponding activity. I tried to do the trick with ContextThemeWrapper but it was no use.
Relevant code:
The activity's onCreate()
The fragment's onCreateView()
The fragment's layout
Attributes
Themes (a lot of them)
I tried to resolve this issue for days now and I still can't find out why this is not working. I haven't found a suitable answer yet and would love some advise.
I've been the victim to my own stupidity. I had another close look on my project setup and found this:
My tablet takes its layout resources from the sw600dp-folder, but I forgot to change the corresponding layout to take attributes instead of hardcoded colors. I think I have to retire after making such a stupid mistake.
Background
On Android, you can set an error indication for any EditText view when you want to show the user that what is typed there (or not typed) is wrong (called "form validations").
There is even a nice library for this (here) , and many post here are available of how to use it.
All worked well for me till I've ran it on a nexus 4 with Android 4.2 .
The problem
Sometimes, it just won't show the icons of the errors. In such a case , only when i give the editText (that has the problem) focus, it shows the bubble, but it's empty and doesn't show the icon of the error.
Also, in all cases, the bubbles are always empty.
Why does it occur, and how can I fix it?
Note: I use actionBarSherlock library so I need to use their themes or a theme that is based on theirs.
EDIT:
here are some screenshots:
android 4.2.2 :
android 2.3.5 :
EDIT:
after i thought that this was solved by itself, i've finally figured out when this bug occurs:
if the focus is on another editText which doesn't have an error, and the error of validation is on another editText , the indicator isn't shown till the editText gets focus.
Problem 1: The problem is the Theme of the application.
Try changing the theme to some darker theme like:
<style name="AppBaseTheme" parent="android:Theme.Black">
and it should solve your problem. I found this similar issue earlier and rectified this by changing the theme.
But I didn't research much but I feel that this is Android issue and the bubble should try to change the text colour according to the theme.
Let me know if it solves your problem, or not.
Problem 2: The other issue you are talking about for not taking focus, you may consider the following link: Text Truncating and Focus Issue.
----------------------------------------Updated Answer---------------------------------------------
Q1) What should I add to the theme configuration in order for it to always work, no matter what theme I use?
According to my findings here are some results:
[Note: Only applicable for devices running 3.0 and up]
If your build target is:
less than 11, then using
parent="android:Theme.Light" --> setError() message doesn't work or shows very faded text colour almost blending with color white
parent="android:Theme" --> setError() message works
greater than 11, then using
parent="android:Theme.Holo.Light" --> setError() message works
parent="android:Theme.Holo" --> setError() message works
Since, your project is supported for devices less than 11 API level and you want to support 4.0 and plus too, your best bet would be to go and integrate HoloEverywhere in your project which will solve your problem and you will be able to use your ActionBarSherlock too, for compatibility, check this SO Post.
Q2) What are the available configurations for the error indication UI ?
Mostly you can customise drawables and icons but I doubt you will be able to configure your text and background(If anyone knows more may point out on this)
I would suggest you to check this SO Post for immediate answers.
And for placing the correct focus, for every validation checks, you may place this code:
EditText.setFocusableInTouchMode(true);
EditText.requestFocus();
EditText.setError("My Error Text");
Let me know for any issues.
'Entry Identifier 0x11a is larger than entry count 0xb2'
This is what's printed in my LogCat when switching to a specific fragment.
I think it may have something to do with my 'xml layout' resource being inflated. I am not sure what though.
My Question
Has anybody else had this problem or know what it means?
Thanks for your help
I've encountered this problem and worked around it with a hack. I added an empty style at the top of my styles.xml:
<style name="empty_style" />
According to this discussion on Google Groups the error occurs
...when HistoryRecord over in the framework is trying to read the theme defined in your resources. There isn't anything wrong with the code [...]. In fact, if you fiddle around with the ordering in your styles.xml, usually adding a few empty blocks near the top, might help get around this
temporarily.
I can't say if the cause quoted above is real, but it removed the issue for me. Hope this helps.