Posts

Showing posts with the label Comparable and comparator interface in android

Sorting Example Using Comparable,Comparator Interface in android

Image
This exmpale will show you how to sort data in android . -This example include sort data on date and string both. -This example will show you how to use both these interfaces. Interfaces //Comarator<//your model name> //Comparable<//your model name> Create a model class:- //class implements comparable interface to store data public class Employee implements Comparable<Employee>{ int id , salary ; String name , email ; String date ; public int getId() { return id ; } public int getSalary() { return salary ; } public String getEmail() { return email ; } public String getName() { return name ; } public void setEmail(String email) { this . email = email; } public void setId( int id) { this . id = id; } public void setName(String name) { this . name = name; } public void setSalary( int salary) { this . salary = salar...