-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RefreshActionItem object in activity is null #7
Comments
Can you post your menu xml, i.e. activity_home.xml? Are you setting the actionViewClass in the menu xml?
|
This is my activity_home.xml menu
|
There is one more thing: I've tried my application on both API Level 10 and API Level 17 of Android, and it has worked fine on only API Level 10, on API Level 17 it has thrown the exception mentioned above. |
How weird. I'll see if I can look into it tomorrow. Thanks for reporting. |
Sorry but I can't seem to reproduce your problem. |
For Android API Level 17 I use the Android emulator, maybe this is the reason of my problem. I will try my app on a device soon and I will tell you the results. |
I Have same issue here ! E/AndroidRuntime(19851): java.lang.NullPointerException |
@coxande I was able to reproduce your logcat error by deliberately misspelling:
in the menu xml. Have you checked you have this line exactly:
? It might not be this but it is best to check. Have you tested your code on different versions of Android like devilmac? |
I have found de problem ! E/AndroidRuntime( 1900): android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01000f a=2} E/AndroidRuntime( 1900): at android.content.res.Resources.loadDrawable(Resources.java:1927) E/AndroidRuntime( 1900): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) E/AndroidRuntime( 1900): at com.manuelpeinado.refreshactionitem.RefreshActionItem.(RefreshActionItem.java:121) Just edit file : com.manuelpeinado.refreshactionitem.RefreshActionItem and comment these two lines: case R.styleable.RefreshActionItem_refreshActionItemBackground: // Drawable drawable = a.getDrawable(attr); // mRefreshButton.setBackgroundDrawable(drawable); break; To get error in logcat I gave made this change in code : @Override public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.main, menu); MenuItem item = menu.findItem(R.id.refresh_button); // mRefreshActionItem = (RefreshActionItem)item.getActionView(); mRefreshActionItem = new RefreshActionItem(getApplicationContext()); item.setActionView(mRefreshActionItem); mRefreshActionItem.setMenuItem(item); mRefreshActionItem.setProgressIndicatorType(ProgressIndicatorType.INDETERMINATE); mRefreshActionItem.setRefreshActionListener(this); return true; } |
@coxande Thanks for helping out. It's not entirely clear to me, though, whether there is something I can change in the library to make your life easier with regard to this issue. If there is, please let me know. |
I had the same exact error as @coxande in a Galaxy Nexus running 4.2.2. My ABS is v4.3.1. May be it has something to do with the error. |
same problem here |
Hi Manuel Peinado,
I'm trying to use this library, I followed your instructions to add this library in my project but I'm experiencing an error in onCreateOptionsMenu method.
This is the body of my onCreateOptionsMenu method:
and I get the NullPointerException in the following line:
mRefreshActionItem.setMenuItem(item);.
As you can see, only the mRefreshActionItem object can be null. My question is: why do I get this exception???
The text was updated successfully, but these errors were encountered: