在日历应用程序中如何在微调器中列出同步帐户名称时避免重复
在构建日历应用程序时,我有一个微调器来显示同步帐户列表。代码如下...我得到了同步帐户的列表。但“联系人的生日和活动”和“印度假期”的重复出现两次,如下图所示。 我的代码是:
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();
}
}
我的屏幕截图:
非常感谢任何帮助,并提前致谢...
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Set ,但它不会允许重复类型。
You could use a Set which wont allow duplicate types.