If you’ve used an AsyncTask before this code should look familiar. Inside the
doInBackground method I make a network request to some given URL, and return the result as a
Boolean. Then in
onPostExecute I could do something with that result.
There is a common pattern I use in all of my RecyclerView adapters to listen for click events on each item.
I created an interface that is similar to the normal click listener, except it also has the position as a parameter.
With this interface I can set up a view holder class as a click listener, and pass in an instance of my interface. Then I set the view itself as a click listener and call my interface with the appropriate position.
In your case you may not want to set the entire view as a click…
Android provides you with a bunch of common views and ways to modify them. Sometimes you need to set a few of the same properties on the same types of views throughout your app. In that case you could make a layout and use the include tag to include it in every layout you need it in. So you can re-use it wherever you need it.
That may be fine, but what if you want to change a property on that view in one place it’s included? For example, you want to change the text colour of a TextView inside…
One of the most common patterns in app development is to have a LoginActivity which transitions to the MainActivity. Once the user has entered the correct credentials, the app starts the MainActivity and finishes the LoginActivity. The problem is, next time when the user launches your app, you don’t want them to have to login again.
There’s a few different approaches you can take, the easiest one being just force them to login every time they use your app. But, that’s a pretty horrible user experience. …
Hi guys, i work as a programmer more than 15 years and was using many different languages, paradigms, frameworks and other shit. And i want to share with you my rules of writing good code.
The (retired) Pub(lication) for Android & Tech, focused on Development