Search in sources :

Example 41 with InflateException

use of android.view.InflateException in project FloatingSearchView by renaudcerrato.

the class FloatingSearchView method inflateMenu.

public void inflateMenu(@MenuRes int menuRes) {
    if (menuRes == 0)
        return;
    if (isInEditMode())
        return;
    getActivity().getMenuInflater().inflate(menuRes, mActionMenu.getMenu());
    XmlResourceParser parser = null;
    try {
        // noinspection ResourceType
        parser = getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs);
    } catch (XmlPullParserException | IOException e) {
        // should not happens
        throw new InflateException("Error parsing menu XML", e);
    } finally {
        if (parser != null)
            parser.close();
    }
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) AttributeSet(android.util.AttributeSet) InflateException(android.view.InflateException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Example 42 with InflateException

use of android.view.InflateException in project grafika by google.

the class AboutBox method display.

/**
 * Displays the About box.  An AlertDialog is created in the calling activity's context.
 * <p>
 * The box will disappear if the "OK" button is touched, if an area outside the box is
 * touched, if the screen is rotated ... doing just about anything makes it disappear.
 */
public static void display(Activity caller) {
    String versionStr = getVersionString(caller);
    String aboutHeader = caller.getString(R.string.app_name) + " v" + versionStr;
    // Manually inflate the view that will form the body of the dialog.
    View aboutView;
    try {
        aboutView = caller.getLayoutInflater().inflate(R.layout.about_dialog, null);
    } catch (InflateException ie) {
        Log.e(TAG, "Exception while inflating about box: " + ie.getMessage());
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(caller);
    builder.setTitle(aboutHeader);
    builder.setIcon(R.drawable.ic_launcher);
    // implies setCanceledOnTouchOutside
    builder.setCancelable(true);
    builder.setPositiveButton(R.string.ok, null);
    builder.setView(aboutView);
    builder.show();
}
Also used : AlertDialog(android.app.AlertDialog) InflateException(android.view.InflateException) View(android.view.View)

Example 43 with InflateException

use of android.view.InflateException in project grafika by google.

the class WorkDialog method create.

/**
 * Prepares an alert dialog builder, using the work_dialog view.
 * <p>
 * The caller should finish populating the builder, then call AlertDialog.Builder#show().
 */
public static AlertDialog.Builder create(Activity activity, int titleId) {
    View view;
    try {
        view = activity.getLayoutInflater().inflate(R.layout.work_dialog, null);
    } catch (InflateException ie) {
        Log.e(TAG, "Exception while inflating work dialog layout: " + ie.getMessage());
        throw ie;
    }
    String title = activity.getString(titleId);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(title);
    builder.setView(view);
    return builder;
}
Also used : AlertDialog(android.app.AlertDialog) InflateException(android.view.InflateException) View(android.view.View)

Example 44 with InflateException

use of android.view.InflateException in project Libraries-for-Android-Developers by eoecn.

the class MenuInflater method inflate.

/**
 * Inflate a menu hierarchy from the specified XML resource. Throws
 * {@link InflateException} if there is an error.
 *
 * @param menuRes Resource ID for an XML layout resource to load (e.g.,
 *            <code>R.menu.main_activity</code>)
 * @param menu The Menu to inflate into. The items and submenus will be
 *            added to this Menu.
 */
public void inflate(int menuRes, Menu menu) {
    XmlResourceParser parser = null;
    try {
        parser = mContext.getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs, menu);
    } catch (XmlPullParserException e) {
        throw new InflateException("Error inflating menu XML", e);
    } catch (IOException e) {
        throw new InflateException("Error inflating menu XML", e);
    } finally {
        if (parser != null)
            parser.close();
    }
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) AttributeSet(android.util.AttributeSet) InflateException(android.view.InflateException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Example 45 with InflateException

use of android.view.InflateException in project ActionBarSherlock by JakeWharton.

the class MenuInflater method inflate.

/**
 * Inflate a menu hierarchy from the specified XML resource. Throws
 * {@link InflateException} if there is an error.
 *
 * @param menuRes Resource ID for an XML layout resource to load (e.g.,
 *            <code>R.menu.main_activity</code>)
 * @param menu The Menu to inflate into. The items and submenus will be
 *            added to this Menu.
 */
public void inflate(int menuRes, Menu menu) {
    XmlResourceParser parser = null;
    try {
        parser = mContext.getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs, menu);
    } catch (XmlPullParserException e) {
        throw new InflateException("Error inflating menu XML", e);
    } catch (IOException e) {
        throw new InflateException("Error inflating menu XML", e);
    } finally {
        if (parser != null)
            parser.close();
    }
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) AttributeSet(android.util.AttributeSet) InflateException(android.view.InflateException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Aggregations

InflateException (android.view.InflateException)100 IOException (java.io.IOException)51 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)48 AttributeSet (android.util.AttributeSet)30 XmlResourceParser (android.content.res.XmlResourceParser)19 Constructor (java.lang.reflect.Constructor)13 View (android.view.View)12 Path (android.graphics.Path)10 SuppressLint (android.annotation.SuppressLint)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 StringTokenizer (java.util.StringTokenizer)6 NonNull (android.annotation.NonNull)5 PathParser (android.util.PathParser)5 TypedValue (android.util.TypedValue)5 NonNull (android.support.annotation.NonNull)4 ExpandedMenuView (android.support.v7.internal.view.menu.ExpandedMenuView)4 ActionBarView (android.support.v7.internal.widget.ActionBarView)4 ViewGroup (android.view.ViewGroup)4 AlertDialog (android.app.AlertDialog)3 LayoutInflater (android.view.LayoutInflater)3