Esempio n. 1
0
		/// <summary>Parse a name/value pair out of an XML tag holding that data.</summary>
		/// <remarks>
		/// Parse a name/value pair out of an XML tag holding that data.  The
		/// AttributeSet must be holding the data defined by
		/// <see cref="android.R.styleable.Extra">android.R.styleable.Extra</see>
		/// .  The following value types are supported:
		/// <ul>
		/// <li>
		/// <see cref="android.util.TypedValue.TYPE_STRING">android.util.TypedValue.TYPE_STRING
		/// 	</see>
		/// :
		/// <see cref="android.os.Bundle.putCharSequence(string, java.lang.CharSequence)">Bundle.putCharSequence()
		/// 	</see>
		/// <li>
		/// <see cref="android.util.TypedValue.TYPE_INT_BOOLEAN">android.util.TypedValue.TYPE_INT_BOOLEAN
		/// 	</see>
		/// :
		/// <see cref="android.os.Bundle.putCharSequence(string, java.lang.CharSequence)">Bundle.putBoolean()
		/// 	</see>
		/// <li>
		/// <see cref="android.util.TypedValue.TYPE_FIRST_INT">android.util.TypedValue.TYPE_FIRST_INT
		/// 	</see>
		/// -
		/// <see cref="android.util.TypedValue.TYPE_LAST_INT">android.util.TypedValue.TYPE_LAST_INT
		/// 	</see>
		/// :
		/// <see cref="android.os.Bundle.putCharSequence(string, java.lang.CharSequence)">Bundle.putBoolean()
		/// 	</see>
		/// <li>
		/// <see cref="android.util.TypedValue.TYPE_FLOAT">android.util.TypedValue.TYPE_FLOAT
		/// 	</see>
		/// :
		/// <see cref="android.os.Bundle.putCharSequence(string, java.lang.CharSequence)">Bundle.putFloat()
		/// 	</see>
		/// </ul>
		/// </remarks>
		/// <param name="tagName">
		/// The name of the tag these attributes come from; this is
		/// only used for reporting error messages.
		/// </param>
		/// <param name="attrs">The attributes from which to retrieve the name/value pair.</param>
		/// <param name="outBundle">The Bundle in which to place the parsed value.</param>
		/// <exception cref="org.xmlpull.v1.XmlPullParserException">If the attributes are not valid.
		/// 	</exception>
		public virtual void parseBundleExtra(string tagName, android.util.AttributeSet attrs
			, android.os.Bundle outBundle)
		{
			android.content.res.TypedArray sa = obtainAttributes(attrs, [email protected]
				.Extra);
			string name = sa.getString([email protected]_name);
			if (name == null)
			{
				sa.recycle();
				throw new org.xmlpull.v1.XmlPullParserException("<" + tagName + "> requires an android:name attribute at "
					 + attrs.getPositionDescription());
			}
			android.util.TypedValue v = sa.peekValue([email protected]_value
				);
			if (v != null)
			{
				if (v.type == android.util.TypedValue.TYPE_STRING)
				{
					java.lang.CharSequence cs = v.coerceToString();
					outBundle.putCharSequence(name, cs);
				}
				else
				{
					if (v.type == android.util.TypedValue.TYPE_INT_BOOLEAN)
					{
						outBundle.putBoolean(name, v.data != 0);
					}
					else
					{
						if (v.type >= android.util.TypedValue.TYPE_FIRST_INT && v.type <= android.util.TypedValue
							.TYPE_LAST_INT)
						{
							outBundle.putInt(name, v.data);
						}
						else
						{
							if (v.type == android.util.TypedValue.TYPE_FLOAT)
							{
								outBundle.putFloat(name, v.getFloat());
							}
							else
							{
								sa.recycle();
								throw new org.xmlpull.v1.XmlPullParserException("<" + tagName + "> only supports string, integer, float, color, and boolean at "
									 + attrs.getPositionDescription());
							}
						}
					}
				}
			}
			else
			{
				sa.recycle();
				throw new org.xmlpull.v1.XmlPullParserException("<" + tagName + "> requires an android:value or android:resource attribute at "
					 + attrs.getPositionDescription());
			}
			sa.recycle();
		}
Esempio n. 2
0
		public virtual void saveActionViewStates(android.os.Bundle outStates)
		{
			android.util.SparseArray<android.os.Parcelable> viewStates = null;
			int itemCount = size();
			{
				for (int i = 0; i < itemCount; i++)
				{
					android.view.MenuItem item = getItem(i);
					android.view.View v = item.getActionView();
					if (v != null && v.getId() != android.view.View.NO_ID)
					{
						if (viewStates == null)
						{
							viewStates = new android.util.SparseArray<android.os.Parcelable>();
						}
						v.saveHierarchyState(viewStates);
						if (item.isActionViewExpanded())
						{
							outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
						}
					}
					if (item.hasSubMenu())
					{
						[email protected] subMenu = ([email protected]
							)item.getSubMenu();
						subMenu.saveActionViewStates(outStates);
					}
				}
			}
			if (viewStates != null)
			{
				outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
			}
		}