小编Cas*_*ngs的帖子

Android Studio希望使用麦克风

我收到一个弹出窗口,其中Android Studio请求访问麦克风的权限。

据我所知,Android Studio中没有语音命令功能。

我发现这很奇怪,我希望有人知道为什么我的IDE想要连接我的麦克风。

ide android jetbrains-ide android-studio

22
推荐指数
1
解决办法
5641
查看次数

如何将BottomAppBar + FAB与BottomNavigationView结合

我想使用FloatingActionButton以及锚定在BottomNavigationView顶部的BottomAppBar上时的行为。

我想出了一个相当“ hacky”的技巧,将其BottomNavigationView放置在BottomAppBar的顶部而不提供背景,从而使其透明。

乍一看,这似乎很好用,但是我发现只有在触摸按钮的上半部分时才能单击fab按钮(因此BottomNavigationView顶部没有透明的地方)。

屏幕截图

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_gravity="bottom"
        app:layout_constraintBottom_toBottomOf="parent">

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:focusable="true"
            app:layout_anchor="@id/bar" />

        <com.google.android.material.bottomappbar.BottomAppBar
            android:id="@+id/bar"
            android:layout_width="match_parent"
            android:layout_height="58dp"
            android:layout_gravity="bottom"
            android:backgroundTint="@color/colorPrimaryDark" />

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottomNavigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:itemIconTint="@android:color/darker_gray"
            app:itemTextColor="@android:color/white"
            app:labelVisibilityMode="labeled"
            app:menu="@menu/navigation" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

有什么办法可以实现我完全可以点击的想法FloatingActionButton

android android-layout android-xml bottomnavigationview android-bottomappbar

11
推荐指数
4
解决办法
6015
查看次数

RxJava:当其中一个流不发出任何信号时如何处理combineLatest()

我使用 mergeLatest() 来组合 3 个可观察数据流。所有这些组合在一起,以便同时显示 UI 中的所有数据。现在,有一种情况,其中一个可观察量不会发出任何内容,因为获取的数据可能为空。

是否有 RxJava 运算符让订阅者知道不会因为空数据而发出任何信号?

编辑

private fun retrieveData() {
    Observable.combineLatest(getCurrentUser.execute(), getLatestGoal.execute(), getLatestLog.execute(),
            Function3<User, Goal, Log, PersonalViewModel> { user, goal, log -> mapToViewModel(user, goal, log) })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnSubscribe { /*todo: animation*/ }
            .doOnNext { view.setViewModel(it) }
            .doOnComplete { view.stopLoading() }
            .doOnError { /*todo: error message*/ }
            .subscribe()
}
Run Code Online (Sandbox Code Playgroud)

第三个流:当用户有 nog 日志时,getLatestLog.execute() 不发出任何内容。当该流不发出时,整个视图将不可见。

数据是从 FireBase 实时数据库中获取的。ChildEventListener 有一个如下所示的方法:

override fun onChildAdded(dataSnapshot: DataSnapshot?, p1: String?) {
                val log = dataSnapshot?.getValue(Log::class.java)
                log?.let { subscriber.onNext(it) }
                subscriber.onComplete()
                firebaseDatabase.reference.removeEventListener(this)
            }
Run Code Online (Sandbox Code Playgroud)

java android rx-java rx-android rx-java2

6
推荐指数
1
解决办法
5605
查看次数

在Android中将Json String转换为List

    strResponse = {"GetCitiesResult":["1-Vizag","2-Hyderbad","3-Pune","4-Chennai","9-123","11-Rohatash","12-gopi","13-Rohatash","14-Rohatash","10-123"]}

 JSONObject json = new JSONObject(strResponse);

            // get LL json object
 String json_LL = json.getJSONObject("GetCitiesResult").toString(); 
Run Code Online (Sandbox Code Playgroud)

现在我想将json字符串转换为andriod中的List

java android json

-2
推荐指数
1
解决办法
881
查看次数