gpt4 book ai didi

android - `android:breadCrumbShortTitle`和 `android:breadCrumbTitle`的区别

转载 作者:行者123 更新时间:2023-11-29 23:56:58 25 4
gpt4 key购买 nike

当我阅读 android.R.attr 时文档中,我找到了 breadCrumbTitlebreadCrumbShortTitle。这两个属性有什么用? android 是否在平台基础上提供面包屑 View ,如果有,它是什么样子的?为什么存在这 2 个属性?

最佳答案

它们用于 PreferenceActivity :

sa.peekValue(com.android.internal.R.styleable.PreferenceHeader_breadCrumbTitle);

具体来说,它们是在从 preference_headers XML 文件中提取的 PreferenceActivity.Header 实例上设置的:

tv = sa.peekValue(com.android.internal.R.styleable.PreferenceHeader_breadCrumbTitle);
if (tv != null && tv.type == TypedValue.TYPE_STRING) {
if (tv.resourceId != 0) {
header.breadCrumbTitleRes = tv.resourceId;
} else {
header.breadCrumbTitle = tv.string;
}
}

不幸的是,关于此功能的用途的文档非常少 - 它出现在哪里,如何在不同的 API 级别上使用等等。official Settings guide甚至没有提到它们。

还有一个概念FragmentBreadCrumbs但这似乎并没有使用这个属性(而且记录更加稀疏!)。

编辑:进一步观察,事实证明这些功能是协同工作的!如果首选项 header 设置了面包屑,那么这些面包屑将与 FragmentBreadCrumbs 小部件结合使用,假设存在一个带有 id android.R.id.title 的小部件,并且我们在多 Pane 首选项页面中:

/**
* Change the base title of the bread crumbs for the current preferences.
* This will normally be called for you. See
* {@link android.app.FragmentBreadCrumbs} for more information.
*/
public void showBreadCrumbs(CharSequence title, CharSequence shortTitle) {
if (mFragmentBreadCrumbs == null) {
View crumbs = findViewById(android.R.id.title);
// For screens with a different kind of title, don't create breadcrumbs.
try {
mFragmentBreadCrumbs = (FragmentBreadCrumbs)crumbs;
} catch (ClassCastException e) {
setTitle(title);
return;
}
if (mFragmentBreadCrumbs == null) {
if (title != null) {
setTitle(title);
}
return;
}
if (mSinglePane) {
mFragmentBreadCrumbs.setVisibility(View.GONE);
// Hide the breadcrumb section completely for single-pane
View bcSection = findViewById(com.android.internal.R.id.breadcrumb_section);
if (bcSection != null) bcSection.setVisibility(View.GONE);
setTitle(title);
}
mFragmentBreadCrumbs.setMaxVisible(2);
mFragmentBreadCrumbs.setActivity(this);
}
if (mFragmentBreadCrumbs.getVisibility() != View.VISIBLE) {
setTitle(title);
} else {
mFragmentBreadCrumbs.setTitle(title, shortTitle);
mFragmentBreadCrumbs.setParentTitle(null, null, null);
}
}

关于android - `android:breadCrumbShortTitle`和 `android:breadCrumbTitle`的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50265629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com