Skip to content

Tag: android

Not able to dynamically set the setVisibility() parameter

I am trying to set the visibility for a button as follows: But I am getting the error: while calling I don’t know how to get around this. I understand that it’s expecting a given set of values but all I know is to pass an int to it. What can be done here? Answer When you know what you’re

onNewIntent in Fragments in android

I am trying to develop a NFC application. I need to recognize the NFC TAG from the OnNewIntent that in the Activity class. Now I need to move and use fragments and not activity. Is their a way to replace the onNewIntent in the fragment class? Answer According to here (https://stackoverflow.com/a/5320694/37369…

How to Change programmatically Edittext Cursor Color in android?

In android we can change the cursor color via: android:textCursorDrawable=”@drawable/black_color_cursor”. How can we do this dynamically? In my case I have set cursor drawable to white, but i need to change black How to do ? Answer Using some reflection did the trick for me Java: XML: Here is a me…

Android Activity without ActionBar

I have different Activities in my App and in all of them I do not want the Action Bar. I cannot find how to disable it. I have tried to find an attribute to apply it to the main_activity.xml but so far I did not find anything. Can somebody help me please? Answer Haha, I have been stuck at that

How to load image from URL in Fragment class?

I want to load an image from its URL in Fragment class. I’m loading the image like this: but this method is taking more time to load the image and to open it. If I want to use ImageLoader class like this tutorial, then how to load it in Fragment? Answer Use any 3rd party library like Picasso. Download t…

openFileOutput() method vs FileOutputStream() constructor

Why in Android one should use openFileOutput() method instead of FileOutputStream() constructor? Would the mode type as a second param of openFileOutput() be the only “respectful” reason for all the cases? Answer Would the mode type as a second param of openFileOutput() be the only “respectf…