当前位置: 首页>>代码示例>>C#>>正文


C# ICursor.GetColumnIndex方法代码示例

本文整理汇总了C#中ICursor.GetColumnIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ICursor.GetColumnIndex方法的具体用法?C# ICursor.GetColumnIndex怎么用?C# ICursor.GetColumnIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICursor的用法示例。


在下文中一共展示了ICursor.GetColumnIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create_Database

        public void Create_Database()
        {
            HashSet<String> tableNameHashSet = new HashSet<String> ();
            tableNameHashSet.Add (WeatherContractOpen.LocationEntryOpen.TABLE_NAME);
            tableNameHashSet.Add (WeatherContractOpen.WeatherEntryOpen.TABLE_NAME);

            context.DeleteDatabase (WeatherDbOpenHelper.DATABASE_NAME);
            SQLiteDatabase db = new WeatherDbOpenHelper (
                                    this.context).WritableDatabase;
            Assert.AreEqual (true, db.IsOpen);

            // have we created the tables we want?
            c = db.RawQuery ("SELECT name FROM sqlite_master WHERE type='table'", null);

            Assert.IsTrue (c.MoveToFirst (), "Error: This means that the database has not been created correctly");

            // verify that the tables have been created
            do {
                tableNameHashSet.Remove (c.GetString (0));
            } while(c.MoveToNext ());

            // if this fails, it means that your database doesn't contain both the location entry
            // and weather entry tables
            Assert.IsTrue (tableNameHashSet.Count == 0, "Error: Your database was created without both the location entry and weather entry tables");

            // now, do our tables contain the correct columns?
            c = db.RawQuery ("PRAGMA table_info(" + WeatherContractOpen.LocationEntryOpen.TABLE_NAME + ")",
                null);

            Assert.IsTrue (c.MoveToFirst (), "Error: This means that we were unable to query the database for table information.");

            // Build a HashSet of all of the column names we want to look for
            HashSet<String> locationColumnHashSet = new HashSet<String> ();
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen._ID);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_CITY_NAME);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LAT);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LONG);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_LOCATION_SETTING);

            int columnNameIndex = c.GetColumnIndex ("name");
            do {
                String columnName = c.GetString (columnNameIndex);
                locationColumnHashSet.Remove (columnName);
            } while(c.MoveToNext ());

            // if this fails, it means that your database doesn't contain all of the required location
            // entry columns
            Assert.IsTrue (locationColumnHashSet.Count == 0, "Error: The database doesn't contain all of the required location entry columns");
            db.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:50,代码来源:TestDbOpen.cs

示例2: BindView

        public override void BindView(View view, Context context, ICursor cursor)
        {
            int image_column_index = cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Id);
            var imageView = (ImageView)view;
            int id = cursor.GetInt(image_column_index);

            Bitmap bm = MediaStore.Images.Thumbnails.GetThumbnail(context.ContentResolver, id, ThumbnailKind.MicroKind, null);

            BitmapDrawable drawable = imageView.Drawable as BitmapDrawable;

            if (drawable != null && drawable.Bitmap != null)
            {
                drawable.Bitmap.Recycle();
            }

            imageView.SetImageBitmap(bm);
        }
开发者ID:adbk,项目名称:spikes,代码行数:17,代码来源:CursorImageAdapter.cs

示例3: GetContacts

		internal static IEnumerable<Contact> GetContacts (ICursor cursor, bool rawContacts, ContentResolver content, Resources resources, int batchSize)
		{
			if (cursor == null)
				yield break;

			string column = (rawContacts)
								? ContactsContract.RawContactsColumns.ContactId
								: ContactsContract.ContactsColumns.LookupKey;

			string[] ids = new string[batchSize];
			int columnIndex = cursor.GetColumnIndex (column);

			HashSet<string> uniques = new HashSet<string>();

			int i = 0;
			while (cursor.MoveToNext())
			{
				if (i == batchSize)
				{
					i = 0;
					foreach (Contact c in GetContacts (rawContacts, content, resources, ids))
						yield return c;
				}

				string id = cursor.GetString (columnIndex);
				if (uniques.Contains (id))
					continue;

				uniques.Add (id);
				ids[i++] = id;
			}

			if (i > 0)
			{
				foreach (Contact c in GetContacts (rawContacts, content, resources, ids.Take(i).ToArray()))
					yield return c;
			}
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:38,代码来源:ContactHelper.cs

示例4: CursorContact

            public CursorContact(ICursor cur)
            {
                var idField = cur.GetColumnIndex(ContactsContract.PhoneLookup.InterfaceConsts.Id);
                var nameField = cur.GetColumnIndex(ContactsContract.PhoneLookup.InterfaceConsts.DisplayName);
                var hasField = cur.GetColumnIndex(ContactsContract.PhoneLookup.InterfaceConsts.HasPhoneNumber);

                Id = cur.GetString(idField);
                DisplayName = cur.GetString(nameField);
                HasPhone = cur.GetString(hasField) != "0";
            }
开发者ID:adbk,项目名称:spikes,代码行数:10,代码来源:Activity1.cs

示例5: GetEmail

		internal static Email GetEmail (ICursor c, Resources resources)
		{
			Email e = new Email();
			e.Address = c.GetString (ContactsContract.DataColumns.Data1);

			EmailDataKind ekind = (EmailDataKind) c.GetInt (c.GetColumnIndex (CommonColumns.Type));
			e.Type = ekind.ToEmailType();
			e.Label = (ekind != EmailDataKind.Custom)
						? ContactsContract.CommonDataKinds.Email.GetTypeLabel (resources, ekind, String.Empty)
						: c.GetString (CommonColumns.Label);

			return e;
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:13,代码来源:ContactHelper.cs

示例6: GetOrganization

		internal static Organization GetOrganization (ICursor c, Resources resources)
		{
			Organization o = new Organization();
			o.Name = c.GetString (OrganizationData.Company);
			o.ContactTitle = c.GetString (OrganizationData.Title);

			OrganizationDataKind d = (OrganizationDataKind) c.GetInt (c.GetColumnIndex (CommonColumns.Type));
			o.Type = d.ToOrganizationType();
			o.Label = (d != OrganizationDataKind.Custom)
						? OrganizationData.GetTypeLabel (resources, d, String.Empty)
						: c.GetString (CommonColumns.Label);

			return o;
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:14,代码来源:ContactHelper.cs

示例7: GetAddress

		internal static Address GetAddress (ICursor c, Resources resources)
		{
			Address a = new Address();
			a.Country = c.GetString (StructuredPostal.Country);
			a.Region = c.GetString (StructuredPostal.Region);
			a.City = c.GetString (StructuredPostal.City);
			a.PostalCode = c.GetString (StructuredPostal.Postcode);

			AddressDataKind kind = (AddressDataKind) c.GetInt (c.GetColumnIndex (CommonColumns.Type));
			a.Type = kind.ToAddressType();
			a.Label = (kind != AddressDataKind.Custom)
						? StructuredPostal.GetTypeLabel (resources, kind, String.Empty)
						: c.GetString (CommonColumns.Label);

			string street = c.GetString (StructuredPostal.Street);
			string pobox = c.GetString (StructuredPostal.Pobox);
			if (street != null)
				a.StreetAddress = street;
			if (pobox != null)
			{
				if (street != null)
					a.StreetAddress += Environment.NewLine;

				a.StreetAddress += pobox;
			}
			return a;
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:27,代码来源:ContactHelper.cs

示例8: GetPhone

		internal static Phone GetPhone (ICursor c, Resources resources)
		{
			Phone p = new Phone();
			p.Number = GetString (c, ContactsContract.CommonDataKinds.Phone.Number);

			PhoneDataKind pkind = (PhoneDataKind) c.GetInt (c.GetColumnIndex (CommonColumns.Type));
			p.Type = pkind.ToPhoneType();
			p.Label = (pkind != PhoneDataKind.Custom)
						? ContactsContract.CommonDataKinds.Phone.GetTypeLabel (resources, pkind, String.Empty)
						: c.GetString (CommonColumns.Label);

			return p;
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:13,代码来源:ContactHelper.cs

示例9: GetRelationship

		internal static Relationship GetRelationship (ICursor c, Resources resources)
		{
			Relationship r = new Relationship { Name = c.GetString (Relation.Name) };

			RelationDataKind rtype = (RelationDataKind)c.GetInt (c.GetColumnIndex (CommonColumns.Type));
			switch (rtype)
			{
				case RelationDataKind.DomesticPartner:
				case RelationDataKind.Spouse:
				case RelationDataKind.Friend:
					r.Type = RelationshipType.SignificantOther;
					break;

				case RelationDataKind.Child:
					r.Type = RelationshipType.Child;
					break;

				default:
					r.Type = RelationshipType.Other;
					break;
			}

			return r;
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:24,代码来源:ContactHelper.cs

示例10: GetImAccount

		internal static InstantMessagingAccount GetImAccount (ICursor c, Resources resources)
		{
			InstantMessagingAccount ima = new InstantMessagingAccount();
			ima.Account = c.GetString (CommonColumns.Data);

			//IMTypeDataKind imKind = (IMTypeDataKind) c.GetInt (c.GetColumnIndex (CommonColumns.Type));
			//ima.Type = imKind.ToInstantMessagingType();
			//ima.Label = InstantMessaging.GetTypeLabel (resources, imKind, c.GetString (CommonColumns.Label));

			IMProtocolDataKind serviceKind = (IMProtocolDataKind) c.GetInt (c.GetColumnIndex (InstantMessaging.Protocol));
			ima.Service = serviceKind.ToInstantMessagingService();
			ima.ServiceLabel = (serviceKind != IMProtocolDataKind.Custom)
								? InstantMessaging.GetProtocolLabel (resources, serviceKind, String.Empty)
								: c.GetString (InstantMessaging.CustomProtocol);

			return ima;
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:17,代码来源:ContactHelper.cs

示例11: GetContact

		internal static Contact GetContact (bool rawContact, ContentResolver content, Resources resources, ICursor cursor)
		{
			string id = (rawContact)
							? cursor.GetString (cursor.GetColumnIndex (ContactsContract.RawContactsColumns.ContactId))
							: cursor.GetString (cursor.GetColumnIndex (ContactsContract.ContactsColumns.LookupKey));

			Contact contact = new Contact (id, !rawContact, content);
			contact.DisplayName = GetString (cursor, ContactsContract.ContactsColumns.DisplayName);

			FillContactExtras (rawContact, content, resources, id, contact);

			return contact;
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:13,代码来源:ContactHelper.cs

示例12: FillContactWithRow

		private static void FillContactWithRow (Resources resources, Contact contact, ICursor c)
		{
			string dataType = c.GetString (c.GetColumnIndex (ContactsContract.DataColumns.Mimetype));
			switch (dataType)
			{
				case ContactsContract.CommonDataKinds.Nickname.ContentItemType:
					contact.Nickname = c.GetString (c.GetColumnIndex (ContactsContract.CommonDataKinds.Nickname.Name));
					break;

				case StructuredName.ContentItemType:
					contact.Prefix = c.GetString (StructuredName.Prefix);
					contact.FirstName = c.GetString (StructuredName.GivenName);
					contact.MiddleName = c.GetString (StructuredName.MiddleName);
					contact.LastName = c.GetString (StructuredName.FamilyName);
					contact.Suffix = c.GetString (StructuredName.Suffix);
					break;

				case ContactsContract.CommonDataKinds.Phone.ContentItemType:
					contact.phones.Add (GetPhone (c, resources));
					break;

				case ContactsContract.CommonDataKinds.Email.ContentItemType:
					contact.emails.Add (GetEmail (c, resources));
					break;

				case ContactsContract.CommonDataKinds.Note.ContentItemType:
					contact.notes.Add (GetNote (c, resources));
					break;

				case ContactsContract.CommonDataKinds.Organization.ContentItemType:
					contact.organizations.Add (GetOrganization (c, resources));
					break;

				case StructuredPostal.ContentItemType:
					contact.addresses.Add (GetAddress (c, resources));
					break;

				case InstantMessaging.ContentItemType:
					contact.instantMessagingAccounts.Add (GetImAccount (c, resources));
					break;

				case WebsiteData.ContentItemType:
					contact.websites.Add (GetWebsite (c, resources));
					break;

				case Relation.ContentItemType:
					contact.relationships.Add (GetRelationship (c, resources));
					break;
			}
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:50,代码来源:ContactHelper.cs

示例13: BindView

			public override void BindView (View view, Context context, ICursor cursor)
			{
				TextView tv = (TextView)view;
				int textIndex = cursor.GetColumnIndex (SearchManager.SuggestColumnText1);
				tv.Text = cursor.GetString (textIndex);
			}
开发者ID:adbk,项目名称:spikes,代码行数:6,代码来源:SearchViews.cs

示例14: BindView

 public override void BindView(View view, Context context, ICursor cursor)
 {
     view.FindViewById<TextView>(Resource.Id.title).Text =
         cursor.GetString(cursor.GetColumnIndex(NoteDatabaseConstants.TitleColumn));
 }
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:5,代码来源:NoteCursorAdapter.cs

示例15: PhonesByCursor

        public System.String PhonesByCursor(ICursor cur)
        {
            System.String phones="";
            int id = cur.GetInt(cur.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.Id));
            if (System.Int16.Parse(cur.GetString(cur.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.HasPhoneNumber))) > 0)
            {
                var loader = new CursorLoader (_context, ContactsContract.CommonDataKinds.Phone.ContentUri,null,ContactsContract.CommonDataKinds.Phone.InterfaceConsts.ContactId +" = "+id,null, null);
                ICursor pCur;
                pCur = (ICursor)loader.LoadInBackground();

            while (pCur.MoveToNext())
                {
                    phones+=pCur.GetString(pCur.GetColumnIndex(ContactsContract.CommonDataKinds.Phone.InterfaceConsts.Data))+"\r\n";
                }
                pCur.Close();
            }
            return phones;
        }
开发者ID:TimHanes,项目名称:ContactCleaner,代码行数:18,代码来源:ContactsHandler.cs


注:本文中的ICursor.GetColumnIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。