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:
Any Help is Really appreciated and Thanks in Advance...
You could use a Set which wont allow duplicate types.
精彩评论