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();
}
}
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();
}
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;
}
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();
}
}
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();
}
}
Aggregations