【发布时间】:2019-11-05 21:20:09
【问题描述】:
此布局来自 Studio 3.5.1 模板。我想不通。但我的问题希望有一个简单的答案。
这是 XML 布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChecklistActivity">
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabAppBarLayout"
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutView"
app:tabMode="scrollable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary" />
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
在我的应用程序 Activity (Java) 中,我想更改 android:label="@string/app_name 文本(在 Activity Manifest 中指定),因为它出现在 Activity 标题(appBar、toolBar 等)上。到目前为止,我还无法做到这一点。
【问题讨论】:
-
我想在该标签中放置一个计时器“(hhh:mm)”,每分钟更新一次。我知道如何编写计时器代码。这不合适吗?更好的选择?
-
感谢您输入 Richard,“为什么”我要更改该标签是否重要?对于 Manifest 中定义的每个活动,该标签都不同。我想根据某些事件更新该标签。在一种情况下,将该活动的经过时间(以小时和分钟为单位)附加到标签上。谢谢
-
为什么是因为我不太明白这个问题,只是想了解更多上下文。
-
我已经更新了我的问题,以便更清楚地了解我想要更改的内容。我不想根据我显示的 XML 布局文件更改清单,只是在我的活动中显示的那个标签。我不知道如何用我的布局做到这一点。