NullPointerException Warning on getView() inside onActivityCreated/onStart/onViewCreated method

I know getView() might return null inside onCreateView() method, but even if I put the below code inside onActivityCreated(), onStart() or onViewCreated() methods, it still shows the warning about a possible NullPointerException in Android Studio (although my program runs without any issue). How to get rid of this warning? I am using Fragments. Code: datpurchased […]

Are the “GONE” views inflated?

I have a huge XML layout, with many Relative / Linear layouts, and what I’m doing now is to hide all the layouts I don’t need with setVisibility (View.GONE) and change their visibility when needed. My question is : is this method sufficient? are the layouts inflated and rendered so they alter the phone memory […]

RecyclerView ScrollListener inside NestedScrollView

I have a EndlessRecyclerView at the end of a NestedScrollView. EndlessRecyclerView means: when user scrolls to the bottom of the recyclerView it loads more data. This is already implemented and working elsewhere but when I put the recyclerView inside the NestedScrollView the OnScrollListener events doesn’t fire. XML design: <NestedScrollView> <Other views/> <EndlessRecyclerView/> </NestedScrollView > Code: […]

Xamarin.Android: How to capture Button events defined in the OnClick XML attribute?

I have this Button inside a RelativeLayout which is included as part of a custom ListView row Layout. <Button p1:text=”Edit” p1:layout_width=”75dp” p1:layout_height=”wrap_content” p1:id=”@+id/editButton” p1:layout_centerHorizontal=”true” p1:background=”@drawable/btn_blue” p1:textColor=”@color/white” p1:focusable=”false” p1:layout_below=”@id/sparyTableLayout” p1:textAppearance=”?android:attr/textAppearanceMedium” p1:onClick=”myClickHandler” /> When the user clicks the Button, I want the Button to call this function: public void myClickHandler(View v) { Console.WriteLine ((v as Button).Text); } […]

Android Compatibility Library CursorLoader : java.lang.IllegalStateException: Cursor is closed

I’m currently using a CursorLoader inside a Fragment with the Android Compatibility Library. Almost every time, on the Droid 2 (I’m unable to reproduce on the Nexus One or the Sensation), it seems that the cursors are being closed too soon, which is causing various errors. Unfortunately the traces don’t point anywhere helpful in my […]

Android JNI functions run on main thread?

I have a doubt regarding JNI function calls made from Android. Do they run on the same thread as the Android app? Will the UI freeze if the native function is taking more time to run?

Android Emulator does not work on Ubuntu after upgrading Android Studio to 2.0 – Qt library not found

Today, I updgraded my Android Studio installation to version 2.0. I updated it manually (download the .zip, because the update mechanism just telled me that there is a new version but offered no possibility for direct update in Android Studio). When I now try to start an emulator, I receive this error message: ERROR:./android/qt/qt_setup.cpp:33:Qt library […]

How to read data from bluetooth barcode scanner Symbol CS3070 to Android Device

In my project i have to read barcodes using barcode scanner Symbol CS3070 through bluetooth. i.e; i have to establish a connection between android device and barcode scanner through bluetooth. Can any one tell me how to read values from barcode reader and how to setup for communication? I’ve already read the Bluetooth Developer Guide, […]

How to get the ID of the clicked child view added dynamically to a LinearLayout?

I am adding a child view to a Linear Layout. The child views itself has some textview and imageviews in a Relativelayout. The child view is added dynamically in the LinearLayout on clicking a button. Right now I am able to add the child view as shown in this pic. http://dl.dropbox.com/u/50249620/SC20120926-031356.png what I have to […]

Save and restore expanded/collapsed state of an ExpandableListActivity

I have an ExpandableListActivity (using a SimpleCursorTreeAdapter) which starts another activity when the user clicks on a child-element. When pressing the back-button in the new activity all the list-items are collapsed again. How do I save the expanded state of the ExpandableListActivity and restore it again. I already tried to implemented onSaveInstanceState() and onRestoreInstanceState() like […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.