是否可以使用 Android Jetpack 导航组件来导航设置首选项的片段?我有一个带有多个嵌套首选项片段的设置屏幕。我想知道使用 Android Jetpack 导航组件来简化我的任务是否可行?
android android-preferences kotlin android-jetpack-navigation
我有一个带有应用内购买的应用程序,我用谷歌提供的测试卡方法来测试它,如下所示Google Play Billing Test
然而,当我在 Google Play 上发布我的应用程序后,我仍然获得测试卡选项。我无法使用真实卡进行付款,如下所示:
我没有使用我的开发者帐户进行付款,并且我的 google play 电子邮件未在许可测试人员中列出。
有人可以帮忙解决这个问题吗?
我在活动中使用片段并使用数据绑定为活动和片段绑定其布局,如下所示:
活动.xml
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@id/FAB_fromHomeActivity_BottomAppBarAttached"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_dark"
android:backgroundTint="@color/colorAccent"
app:layout_anchor="@id/BottomAppBar_fromHomeActivity_Main"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)
活动.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mBinding = DataBindingUtil.setContentView(this, R.layout.activity)
}
Run Code Online (Sandbox Code Playgroud)
片段.kt
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_goals, container, false)
return mBinding.root
}
Run Code Online (Sandbox Code Playgroud)
有没有办法使用片段中的绑定访问活动中的 FAB?(例如类似 mBinding.parent.FAB 的东西)
我找不到这方面的任何信息。任何人都可以帮忙吗?
我的应用程序目前是使用单一活动方法实现的(使用具有一个主要活动和多个片段的导航架构组件)。我目前正在使用带抽屉的工具栏。
我的应用程序目前看起来像这样:
然而,在现代谷歌应用程序(谷歌照片、gmail 等)中,谷歌实现了一种使用搜索字段进行导航的新方法,其中包含一个已实现的抽屉,如下所示:
我想用搜索栏和抽屉菜单替换这个工具栏,就像 Google 应用程序一样。
有人可以帮助我编写一些关于如何实现此目标的代码吗?
我的主要活动如下:
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/Drawer_Main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.main.MainActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/Toolbar_Main"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<TextView
android:id="@+id/Toolbar_Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
style="@style/Locky.Toolbar.TitleText" />
</com.google.android.material.appbar.MaterialToolbar>
<androidx.core.widget.NestedScrollView
android:id="@+id/Nested_Scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<fragment
android:id="@+id/Navigation_Host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_drawer_main" />
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:orientation="vertical">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/FAB_Account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:visibility="invisible"
app:srcCompat="@drawable/ic_account"
style="@style/Locky.FloatingActionButton.Mini" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/FAB_Card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:visibility="invisible"
app:srcCompat="@drawable/ic_credit_card"
style="@style/Locky.FloatingActionButton.Mini" …Run Code Online (Sandbox Code Playgroud) android kotlin android-search android-drawer android-architecture-navigation
我有一个使用导航组件构建的应用程序。我的图表中有一个字段,单击工具栏上的过滤器图标后,该字段会向上滑动底部工作表对话框片段。但是,如果我非常快速地双击工具栏过滤器图标,或者非常快速地单击工具栏过滤器图标和任何与其关联的导航的其他视图,我的应用程序将崩溃并显示以下错误消息:
java.lang.IllegalArgumentException: navigation destination com.th3pl4gu3.locky:id/action_Fragment_Card_to_Fragment_View_Card is unknown to this NavController
Run Code Online (Sandbox Code Playgroud)
下面是我的工具栏过滤器图标的代码示例。
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.Toolbar_Filter -> {
findNavController().navigate(CardFragmentDirections.actionFragmentCardToBottomSheetFragmentCardFilter())
true
}
else -> false
}
}
Run Code Online (Sandbox Code Playgroud)
这是导航架构组件的正常行为吗?
如果没有,您能为我提供修复吗?
android kotlin android-architecture-navigation android-jetpack-navigation android-bottomsheetdialog
是否可以在启动画面的布局中加载 Lottie 动画?
目前我的启动画面布局是这样的:
背景文件
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@drawable/path_background_gradient" />
<item
android:drawable="@drawable/ic_locky"
android:gravity="center" />
</layer-list>
Run Code Online (Sandbox Code Playgroud)
样式文件
<!-- Splash Launcher UI theme. -->
<style name="Locky.Theme.Launcher" parent="Locky.Theme">
<item name="android:windowBackground">@drawable/custom_background_launcher</item>
<item name="colorPrimary">@color/background_gradient_accent_start</item>
<item name="colorPrimaryDark">@color/background_gradient_accent_start</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我用它来防止 android 冷启动时出现白屏。
但是ic_locky我想使用 Lottie 动画而不是图标。有可能这样做吗?因为有许多应用程序在启动画面中使用动画徽标。
请帮我。
谢谢你们。
我有一个内置在 Flask 中的 Web 应用程序,可以在其中捕获推文(使用 Tweepy 库)并显示在前端。我使用 Socket IO 在前端实时显示推文。
当我在本地运行它时,我的代码工作正常。推文立即出现。
但是,当我对 Web 应用程序进行 Docker 化时,前端不会立即更新。显示更改需要一些时间(有时我认为由于缓慢而丢失了推文)
以下是我网站的代码摘录:
fortsocket.js
$(document).ready(function () {
/************************************/
/*********** My Functions ***********/
/************************************/
function stream_active_setup() {
$("#favicon").attr("href", "/static/icons/fortnite-active.png");
$("#stream-status-ic").attr("src", "/static/icons/stream-active.png");
$("#stream-status-text").text("Live stream active");
}
function stream_inactive_setup() {
$("#favicon").attr("href", "/static/icons/fortnite-inactive.png");
$("#stream-status-ic").attr("src", "/static/icons/stream-inactive.png");
$("#stream-status-text").text("Live stream inactive");
}
/*********************************/
/*********** My Events ***********/
/*********************************/
// Socket connection to server
// Prometheus
//var socket = io.connect('http://104.131.173.145:8083');
// Local
var socket = io.connect(window.location.protocol + '//' + document.domain + ':' + location.port); …Run Code Online (Sandbox Code Playgroud) 我有一个用 Jetpack Compose 编写的 Android 应用程序。我正在尝试使用应用程序中定义的 colorScheme 设置图标颜色,但它不起作用。
下面是我的代码。
颜色.kt
import androidx.compose.ui.graphics.Color
val green = Color(0xFF61FF67)
Run Code Online (Sandbox Code Playgroud)
主题.kt
private val MesColorDark = darkColorScheme(
primary = green,
secondary = green,
tertiary = green,
surface = green
)
private val MesColorLight = lightColorScheme(
primary = green,
secondary = green,
tertiary = green,
surface = green
)
@Composable
fun MesTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val mesColorScheme =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val context = LocalContext.current
if …Run Code Online (Sandbox Code Playgroud) android material-design android-jetpack-compose android-jetpack-compose-material3 material3
我有一个 Flask 应用程序,它使用 SocketIO 从 Postgres 实时获取数据。
当我在本地运行该应用程序时,该应用程序运行良好。
当我使用 docker-compose 来托管我的 Flask 应用程序时,问题就出现了。我的 JS 客户端和 Flask 服务器托管在一个应用程序和同一个容器中。
我在 JS 中的 socketio 是这样的:
var socket = io().connect(window.location.protocol + '//' + document.domain + ':' + location.port);
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
# Using python 3.7 in Alpine
FROM python:3.6.5-stretch
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
RUN apt-get update -y && apt-get upgrade -y
# Install the dependencies from requirements …Run Code Online (Sandbox Code Playgroud) android ×8
kotlin ×6
android-architecture-navigation ×2
docker ×2
flask ×2
socket.io ×2
android-jetpack-compose-material3 ×1
google-play ×1
gunicorn ×1
lottie ×1
material3 ×1
menu ×1
python ×1