0

I have a calendar like this:

materialise calendar

every tic icon shows their corresponding event.

and I have a json response like this:

{
    "Table": [
        {
            "userid": 4,
            "eventname": "adi",
            "eventdate": "/Date(1484121600000-0800)/",
            "eventcolor": "2413AD",
            "autoid": 2005
        },
        {
            "userid": 4,
            "eventname": "Aditya",
            "eventdate": "/Date(1479974400000-0800)/",
            "eventcolor": "5986FF",
            "autoid": 1011
        },
        {
            "userid": 4,
            "eventname": "aditya",
            "eventdate": "/Date(1484812800000-0800)/",
            "eventcolor": "13AD1A",
            "autoid": 2006
        },
        {
            "userid": 4,
            "eventname": "dfgdgdgs",
            "eventdate": "/Date(1478678400000-0800)/",
            "eventcolor": "AD3D1F",
            "autoid": 1005
        },
        {
            "userid": 4,
            "eventname": "dfgdgdgs",
            "eventdate": "/Date(1478678400000-0800)/",
            "eventcolor": "AD3D1F",
            "autoid": 1006
        }
    ]
}

Here comes the real problem.When I click any date on the calendar, above json response comes in a listView according to sequence of json. But, I want to change the sequence according to which date i clicked(i.e. Date i am clicked in the calendar, that date comes first in the list and remaining item comes after that).

I'm not posting any code, If any one wants to see my code, please ask.

Noorul
  • 3,386
  • 3
  • 32
  • 54

1 Answers1

0

When you parse the list from JSON at that time you check the date of each object and compare to the clicked date and store that particular index. Then you simply parse the list from JSON response at parsing time you remove that particular object at that stored index and move to the first position of that list. Use code like:

list.removeAt(stored_index);
list.add(0, objectOfList);

and then simply add that list to adapter

Vijay Makwana
  • 506
  • 5
  • 14
  • Can U please explain something more@Vijay. i.e. what is stored_index and objectOfList. –  Jan 12 '17 at 07:38
  • stored_index is the position of the object in response list who has the date equals to your date was clicked. And objectOfList is the object of the list at the position of stored_index. – Vijay Makwana Jan 12 '17 at 09:10