Skip to main content

Posts

How to sort a list in ascending order and Add header by the first letter in the RecyclerView in Android

Hello Forks ! Hope you are doing well. In this tutorial we will understand how to sort a list of data, it could be any data like bank names , places names etc. in ascending order with a header which grouped the same type of data under it. For example we have a list of banks data and we want to group all banks starting with 'A' character in single unit and so on. So without taking too much time  let's move to the coding part and understand how we can achieve this. Step 1 : Create a Model class Named Bank.java public class Bank { private String name; public Bank (String name) { this .name = name; } public String getName () { return name; } } Step 2 : Sort the List of Banks with this Method import java.util.Collections; import java.util.Comparator; import java.util.List; public void sortBankList (List<Bank> bankList) { Collections.sort(bankList, new Comparator <Bank>() { @Override pub...
Recent posts

How to implement View Swap with Animation in Android

 Hello Guys, Hope you are doing well. In this tutorial we will implement an app in which views are swapping with each other with some animation . For example one view is on top and we want to swap the last view with this first view. so we will implement in this tutorial step by step.so without wasting time lets move to coding part. Step 1: Create an xml file with name activity_main.xml <?xml version= "1.0" encoding= "utf-8" ?> < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" xmlns:app = "http://schemas.android.com/apk/res-auto" xmlns:tools = "http://schemas.android.com/tools" android:layout_width = "match_parent" android:layout_height = "match_parent" android:orientation = "vertical" > < ScrollView android:layout_width = "match_parent" android:layout_height = "wrap_content" an...