开发者

In calendar application How to avoid duplication of synchronized account name while listing them in spinner

In building Calendar application i have a spinner to display the list of synchronized accounts. The Code is given below... I get the list of synchronized accounts. But repitition of "Contacts' birthdays and events" and "Indian Holidays " are coming twice as below screenshot. MY CODE IS:

    final ContentResolver cr = ctx.getContentResolver();
    Cursor cursor ;
    if (Integer.parseInt(Build.VERSION.SDK) >= 9 )
    {
        cursor = cr.query(Uri.parse("content://com.android.calendar/calendars"), new String[]{ "_id", "name" }, null, null, "_id");
    }
    else
        cursor = cr.query(Uri.parse("content://com.android.calendar/calendars"), new String[]{ "_id", "name" }, null, null, "_id");
    if ( 开发者_运维问答cursor.moveToFirst()) 
    {
        calNames = new String[cursor.getCount()];
        final int[] calIds = new int[cursor.getCount()];
        for (int i = 0; i < (calNames.length); i++)
        {
            calIds[i] = cursor.getInt(0);
            calNames[i] = cursor.getString(1);
            cursor.moveToNext();
        }

    }

MY SCREENSOT:

In calendar application How to avoid duplication of synchronized account name while listing them in spinner

Any Help is Really appreciated and Thanks in Advance...


You could use a Set which wont allow duplicate types.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜