本文整理汇总了Java中android.support.annotation.XmlRes类的典型用法代码示例。如果您正苦于以下问题:Java XmlRes类的具体用法?Java XmlRes怎么用?Java XmlRes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlRes类属于android.support.annotation包,在下文中一共展示了XmlRes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPreferencesFromResource
import android.support.annotation.XmlRes; //导入依赖的package包/类
@Override
public void addPreferencesFromResource(@XmlRes int preferencesResId) {
super.addPreferencesFromResource(preferencesResId);
Executor executor = (runnable) -> new Thread(runnable).start();
ProviderInfoRetriever.OnProviderInfoReceivedCallback callback = new ProviderInfoRetriever.OnProviderInfoReceivedCallback() {
@Override
public void onProviderInfoReceived(int i, @Nullable ComplicationProviderInfo complicationProviderInfo) {
setComplicationSummary(i, complicationProviderInfo);
}
};
mProviderInfoRetriever = new ProviderInfoRetriever(mContext, executor);
mProviderInfoRetriever.init();
mProviderInfoRetriever.retrieveProviderInfo(callback,
new ComponentName(mContext, IOClassicWatchFaceService.class),
IOClassicWatchFaceService.COMPLICATION_IDS);
}
示例2: show
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Setup for ChangelogDialog
*
* @param activity activity for context
* @param xmlRes xmlRes of Changelog file
* @param neutralCallback optional callback & string for neutral button
*/
public static void show(@NonNull final FragmentActivity activity, @XmlRes final int xmlRes,
@Nullable final OnChangelogNeutralButtonClick neutralCallback) {
final Handler mHandler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
final ArrayList<ChangelogXmlParser.ChangelogItem> items = ChangelogXmlParser
.parse(activity, xmlRes);
mHandler.post(new TimerTask() {
@Override
public void run() {
ChangelogDialog f = new ChangelogDialog()
.setNeutralCallback(neutralCallback);
if (!items.isEmpty()) {
Bundle args = new Bundle();
args.putParcelableArrayList(ITEM_TAG, items);
f.setArguments(args);
}
f.show(activity.getSupportFragmentManager(), DIALOG_TAG);
}
});
}
}).start();
}
示例3: setPreferencesFromResource
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Inflates the given XML resource and replaces the current preference hierarchy (if any) with
* the preference hierarchy rooted at {@code key}.
*
* @param preferencesResId The XML resource ID to inflate.
* @param key The preference key of the {@link PreferenceScreen} to use as the root of the
* preference hierarchy, or null to use the root {@link PreferenceScreen}.
*/
public void setPreferencesFromResource(@XmlRes int preferencesResId, @Nullable String key) {
requirePreferenceManager();
final PreferenceScreen xmlRoot = mPreferenceManager.inflateFromResource(mStyledContext,
preferencesResId, null);
final Preference root;
if (key != null) {
root = xmlRoot.findPreference(key);
if (!(root instanceof PreferenceScreen)) {
throw new IllegalArgumentException("Preference object with key " + key
+ " is not a PreferenceScreen");
}
} else {
root = xmlRoot;
}
setPreferenceScreen((PreferenceScreen) root);
}
示例4: draft
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Draft a changelog recycler view ready to be displayed
*
* @param ctx the context to construct the view with
* @param configId the xml configuration resource id
* @return the built RecyclerView ready for insertion
*/
public static RecyclerView draft(Context ctx, @XmlRes int configId){
// Parse config
ChangeLog changeLog = Parser.parse(ctx, configId);
// Setup the adapter
ChangeLogAdapter adapter = new ChangeLogAdapter();
adapter.setChangeLog(changeLog);
// Parse the configuration from the resource ID and generate a RecyclerView that is ready to go
RecyclerView recycler = new RecyclerView(ctx);
recycler.setAdapter(adapter);
recycler.setLayoutManager(new LinearLayoutManager(ctx));
recycler.setItemAnimator(new DefaultItemAnimator());
recycler.addItemDecoration(new StickyRecyclerHeadersElevationDecoration(adapter));
return recycler;
}
示例5: checkChangelogActivity
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Check to see if we should show the changelog activity if there are any new changes
* to the configuration file.
*
* @param ctx the context to launch the activity with
* @param configId the changelog configuration xml resource id
*/
public static void checkChangelogActivity(Context ctx, @XmlRes int configId){
// Parse configuration
ChangeLog changeLog = Parser.parse(ctx, configId);
if(changeLog != null){
// Validate that there is a new version code
if(validateVersion(ctx, changeLog)) {
openChangelogActivity(ctx, configId);
}
}else{
throw new NullPointerException("Unable to find a 'Winds' configuration @ " + configId);
}
}
示例6: checkChangelogDialog
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Check to see if we should show the changelog activity if there are any new changes
* to the configuration file.
*
* @param ctx the context to launch the activity with
* @param configId the changelog configuration xml resource id
*/
public static void checkChangelogDialog(Activity ctx, @XmlRes int configId){
// Parse configuration
ChangeLog changeLog = Parser.parse(ctx, configId);
if(changeLog != null){
// Validate that there is a new version code
if(validateVersion(ctx, changeLog)) {
openChangelogDialog(ctx, configId);
}
}else{
throw new NullPointerException("Unable to find a 'Winds' configuration @ " + configId);
}
}
示例7: getItemsFromXml
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
*
*/
protected ArrayList<TwinTextItem> getItemsFromXml(@XmlRes int xmlResource)
throws XmlPullParserException, IOException {
final Resources res = getResources();
XmlResourceParser parser = res.getXml(xmlResource);
ArrayList<TwinTextItem> items = new ArrayList<>();
int eventType;
while((eventType = parser.next()) != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_TAG) {
// call our subclass to parse the correct item
TwinTextItem item = parseItemFromXmlTag(parser);
if(item != null)
items.add(item);
}
}
return items;
}
示例8: show
import android.support.annotation.XmlRes; //导入依赖的package包/类
public static void show(FragmentActivity fragmentActivity,
@StringRes int resEulaTitle,
@StringRes int resEulaAcceptLabel,
@StringRes int resEulaRefuseLabel,
@StringRes int resChangeLogTitle,
@StringRes int resChangeLogClose,
@XmlRes int resChangeLog) {
//not shown = already accepted
boolean shown = EulaHelper.showAcceptRefuse(fragmentActivity, resEulaTitle, resEulaAcceptLabel, resEulaRefuseLabel);
ChangeLogHelper changeLogHelper = new ChangeLogHelper();
if (!shown) {
changeLogHelper.showWhatsNew(resChangeLogTitle, resChangeLogClose, resChangeLog, fragmentActivity);
} else {
//We don't show the changelog at first run of the first install, but we have to save the current version
//for the future upgrades
changeLogHelper.saveCurrentVersion(fragmentActivity);
}
}
示例9: getXml
import android.support.annotation.XmlRes; //导入依赖的package包/类
@Override
public XmlResourceParser getXml(@XmlRes int id) throws NotFoundException {
int realId = getCorrespondResIdStrictly(id);
if (realId > 0) {
return mSkinResources.getXml(realId);
}
return super.getXml(id);
}
示例10: setItems
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Set the item for the BottomBar from XML Resource with a default configuration
* for each tab.
*/
public void setItems(@XmlRes int xmlRes, BottomBarTab.Config defaultTabConfig) {
if (xmlRes == 0) {
throw new RuntimeException("No items specified for the BottomBar!");
}
if (defaultTabConfig == null) {
defaultTabConfig = getTabConfig();
}
TabParser parser = new TabParser(getContext(), defaultTabConfig, xmlRes);
updateItems(parser.getTabs());
}
示例11: TabParser
import android.support.annotation.XmlRes; //导入依赖的package包/类
TabParser(Context context, BottomBarTab.Config defaultTabConfig, @XmlRes int tabsXmlResId) {
this.context = context;
this.defaultTabConfig = defaultTabConfig;
parser = context.getResources().getXml(tabsXmlResId);
tabs = new ArrayList<>();
parse();
}
示例12: newInstance
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Method do get an instance of the Fragment
* Needed to reuse.
*
* @param category_xml the XML file to load in UI
* @return SettingsFragment
*/
public static SettingsFragment newInstance(@XmlRes int category_xml) {
SettingsFragment instance = new SettingsFragment();
Bundle b = new Bundle();
b.putInt(Presenter.CATEGORY, category_xml);
instance.setArguments(b);
return instance;
}
示例13: replaceFragment
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* To replace the current fragment, with new xml to show.
*
* @param resid the xml UI to show in the fragment
*/
@Override
public void replaceFragment(@XmlRes int resid) {
Fragment fragment = SettingsFragment.newInstance(resid);
getFragmentManager()
.beginTransaction()
.addToBackStack(null)
.replace(R.id.frame_layout, fragment, Contract.Presenter.CATEGORY_TAG)
.commit();
}
示例14: showFragment
import android.support.annotation.XmlRes; //导入依赖的package包/类
public void showFragment(@XmlRes int preferenceId, @StringRes int title) {
//TODO: cache the Fragments so they can be reused
getFragmentManager().beginTransaction()
.replace(R.id.fragment_container, PreferencesFragment.newInstance(preferenceId))
.commit();
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(title);
}
currentPreferences = preferenceId;
currentTitle = title;
}
示例15: setItems
import android.support.annotation.XmlRes; //导入依赖的package包/类
/**
* Set the item for the BottomBar from XML Resource with a default configuration
* for each tab.
*/
public void setItems(@XmlRes int xmlRes, BottomBarTab.Config defaultTabConfig) {
if (xmlRes == 0) {
throw new RuntimeException("No items specified for the BottomBar!");
}
if (defaultTabConfig == null) {
defaultTabConfig = getTabConfig();
}
TabParser parser = new TabParser(getContext(), defaultTabConfig, xmlRes);
updateItems(parser.parseTabs());
}