It might sound simple but I can’t make it working. I have two activities. Which first one is a form, and second one is showing data from a JSON file based on values entered in the first activity. So I am trying to make a simple version of it. I have a EditText, and a button, so when they press
Tag: android
how to add button click event in android studio
So I have done some research, and after defining you button as an object by the code here is my problem then your OnClick() event… Problem: When I type in the “this”, it says: I have no idea why? here is the code from the .java file Answer SetOnClickListener (Android.View.view.OnClickListene…
android : Check EditText is null
i want to check and give condition to my edittext, if i input something to my edittext, l it will change my imageview, this is my code: i have problem here, my imageview not change…. is this code has true or not? Answer If I read your post correctly, you want to check if the EditText is ever empty as
Create and populate TreeMap in one line
Like an array new Integer[]{ 1, 2, 3 }, can I create and populate a TreeMap using just one line? Any chances for HashMap or LinkedHashMap too? Answer There is no built-in syntax for specifically initializing maps. However, you can take advantage of a special syntax known as “double brace initialization&…
Is it bad practice to keep data in static variables?
In an Android application, is it bad practice to store objects in static fields in these cases? Application data. Is it bad to keep application data in static variables in a class while the application is running? Currently, I’m storing the data in an instance variable in my Application class. Then clas…
How to exit a while loop after a certain time?
I have a while loop and I want it to exit after some time has elapsed. For example: Answer Thus the statement Checks if it has been 10 seconds or 10,000 milliseconds since the loop started. EDIT As @Julien pointed out, this may fail if your code block inside the while loop takes a lot of time.Thus using Execu…
Convert minutes into a human readable format
quick question. Is there a smarter/sleeker way to convert minutes into a more readable format, showing only the most significant digit? I’m using Android Studio’s Java. ie My code is very cumbersome, sloppy, and somewhat unreadable. Many thanks, J Answer Well it is possible, I figure it out and I …
Saving byte array using SharedPreferences
So I have a byte [] array which I have created in my android app. I want to use SharedPreferences from android to store it and retrieve it back again when I start my app. How can I do that ? Answer You could try to save it has a String: Storing the array: Retrieving the array:
WakefulBroadcastReceiver cannot be resolved to a type
My project shows error message that WakefulBroadcastReceiver cannot be resolved to a type. I looked up for all possible reasons I can think of. I have set android-support-library and google play services’s path. Even my mapView works (if I comment below code) that means google play service is correctly …
How to use interface to communicate between two activities
I am trying to make listener interface between two activities Act1 and Act2. Act1 will start Act2. If there is some event occurred in Act2, it will inform it to Act1. Problem is that I am starting new activity using Intent, so how Act1 will assign itself as listener to Act2’s interface? Act1.java Act2.j…