本文整理了Java中android.content.res.Resources.getLayout
方法的一些代码示例,展示了Resources.getLayout
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resources.getLayout
方法的具体详情如下:
包路径:android.content.res.Resources
类名称:Resources
方法名:getLayout
暂无
代码示例来源:origin: code-mc/material-icon-lib
private void afterInflate(int menuRes, Menu menu){
IconData root = new IconData(0, 0, 0);
XmlResourceParser parser = null;
try {
parser = mContext.getResources().getLayout(menuRes);
AttributeSet attrs = Xml.asAttributeSet(parser);
parseMenu(parser, attrs, root);
} 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();
// populate the menu with the parsed icons
populateIcons(menu, root, mDefaultColor);
}
}
代码示例来源:origin: stackoverflow.com
AttributeSet as = null;
Resources r = getResources();
XmlResourceParser parser = r.getLayout(R.layout.testcameraoverlay);
int state = 0;
do {
try {
state = parser.next();
} catch (XmlPullParserException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
if (state == XmlPullParser.START_TAG) {
if (parser.getName().equals("TextView")) {
as = Xml.asAttributeSet(parser);
break;
}
}
} while(state != XmlPullParser.END_DOCUMENT);
代码示例来源:origin: baidu/GPT
@Override
public XmlResourceParser getLayout(int id) throws NotFoundException {
try {
return super.getLayout(id);
} catch (NotFoundException e) {
return mHostResources.getLayout(id);
}
}
代码示例来源:origin: iqiyi/Neptune
@Override
public XmlResourceParser getLayout(int id) throws NotFoundException {
try {
return super.getLayout(id);
} catch (NotFoundException e) {
return mHostResources.getLayout(id);
}
}
代码示例来源:origin: wasdennnoch/AndroidN-ify
public final XmlResourceParser getLayout(@LayoutRes int resId) {
return mContext.getResources().getLayout(resId);
}
代码示例来源:origin: stackoverflow.com
Resources r = getResources();
XmlResourceParser parser = r.getLayout(R.layout.your_layout);
int state = 0;
do {
try {
state = parser.next();
} catch (XmlPullParserException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
if (state == XmlPullParser.START_TAG) {
//here get the attributes you want..., with AttributeSet for example
}
}
} while(state != XmlPullParser.END_DOCUMENT);
代码示例来源:origin: hamidness/restring
private Map<Integer, MenuItemStrings> getMenuItemsStrings(Resources resources, int resId) {
XmlResourceParser parser = resources.getLayout(resId);
AttributeSet attrs = Xml.asAttributeSet(parser);
try {
return parseMenu(parser, attrs);
} catch (XmlPullParserException | IOException e) {
e.printStackTrace();
return new HashMap<>();
}
}
代码示例来源:origin: flipkart-incubator/proteus
private void initializeAttributeSet(@NonNull ViewGroup parent) {
sParser = parent.getResources().getLayout(R.layout.layout_params_hack);
//noinspection StatementWithEmptyBody
try {
//noinspection StatementWithEmptyBody
while (sParser.nextToken() != XmlPullParser.START_TAG) {
// Skip everything until the view tag.
}
} catch (XmlPullParserException | IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: itzuo/ShoppingCart
private void initView(Context context, Resources resources, View content) {
// TODO Auto-generated method stub
setOrientation(LinearLayout.HORIZONTAL);
this.mContext = context;
this.mResources = resources;
Log.i(TAG, "---1---");
mScroller = new Scroller(context);
Log.i(TAG, "---2---");
View view = LayoutInflater.from(context).inflate(resources.getLayout(R.layout.slide_view_merge), this);
Log.i(TAG, "---3---");
// view.findViewById(R.id.holder).setBackground(resources.getDrawable(R.drawable.selector_slider_holder));
Log.i(TAG, "---4---");
// shenhe = (TextView) view.findViewById(R.id.shenhe);
// back = (TextView) findViewById(R.id.back);
// back.setCompoundDrawablesWithIntrinsicBounds(null, resources.getDrawable(R.drawable.back), null, null);
// back.setOnClickListener(this);
// shenhe.setOnClickListener(this);
mViewContent = (LinearLayout) view.findViewById(R.id.view_content);
// mHolderWidth = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mHolderWidth, getResources().getDisplayMetrics()));
mHolderWidth = getResources().getDimensionPixelSize(R.dimen.width_);
if(content!=null){
mViewContent.addView(content);
}
}
代码示例来源:origin: stackoverflow.com
XmlResourceParser xmlResourceLayout = packageResources.getLayout(id);
代码示例来源:origin: stackoverflow.com
Drawable drawable = resources.getDrawable(id);
}else if(resourceType.getName().equals(layoutClassName)){
XmlResourceParser layout = resources.getLayout(id);
代码示例来源:origin: lvfaqiang/HomePageFilter
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View mView = inflater.inflate(
getResources().getLayout(R.layout.fragment_bannervp),
container, false);
initView(mView);
setTestData();
return mView;
}
代码示例来源:origin: stackoverflow.com
public View inflate(int resource, ViewGroup root, boolean attachToRoot) {
final Resources res = getContext().getResources();
if (DEBUG) {
Log.d(TAG, "INFLATING from resource: \"" + res.getResourceName(resource) + "\" ("
+ Integer.toHexString(resource) + ")");
}
final XmlResourceParser parser = res.getLayout(resource);
try {
return inflate(parser, root, attachToRoot);
} finally {
parser.close();
}
}
代码示例来源:origin: CvvT/AppTroy
private String getLayout(int id) {
XmlResourceParser parser = mContext.getResources().getLayout(id);
try {
StringBuilder sb = new StringBuilder();
代码示例来源:origin: com.actionbarsherlock/actionbarsherlock
/**
* 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();
}
}
代码示例来源:origin: com.willowtreeapps/oak-demos
/**
* 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();
}
}
代码示例来源:origin: stackoverflow.com
try {
Resources resources = getPackageManager().getResourcesForApplication(packageName);
XmlResourceParser xpp = resources.getLayout(prefsId);
xpp.next();
String action = null;
代码示例来源:origin: SamuelGjk/GComic
public void inflateMenu(@MenuRes int menuRes) {
if (menuRes == 0) 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();
}
}
代码示例来源:origin: blockchain/Android-Merchant-App
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(getResources().getLayout(R.layout.fragment_transaction), container, false);
initListView(rootView);
merchantXpub = PrefsUtil.getInstance(getActivity()).getValue(PrefsUtil.MERCHANT_KEY_MERCHANT_RECEIVER, "");
push_notifications = PrefsUtil.getInstance(getActivity()).getValue(PrefsUtil.MERCHANT_KEY_PUSH_NOTIFS, false);
doBTC = PrefsUtil.getInstance(getActivity()).getValue(PrefsUtil.MERCHANT_KEY_CURRENCY_DISPLAY, false);
btc_font = TypefaceUtil.getInstance(getActivity()).getTypeface();
swipeLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
swipeLayout.setProgressViewEndTarget(false, (int) (getResources().getDisplayMetrics().density * (72 + 20)));
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new GetDataTask().execute();
}
});
swipeLayout.setColorScheme(R.color.blockchain_blue,
R.color.blockchain_green,
R.color.blockchain_dark_blue);
thisActivity = getActivity();
return rootView;
}
内容来源于网络,如有侵权,请联系作者删除!