小编vik*_*mar的帖子

AlertDialog 的 Leanback 版本

在 Android 中,制作AlertDialog带有Positive/Negative按钮的按钮很容易。

new AlertDialog.Builder(getActivity())
           .setTitle("Question?")
           .setPositiveButton("YES", new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int which) {
                   // User chose YES
               }
           })
           .setNegativeButton("NO", new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialogInterface, int i) {
                   // User chose NO
                }
           }).create().show();
Run Code Online (Sandbox Code Playgroud)

我想在我的TV App 中制作等价物。(向用户提问,得到 Yes/No 响应)

我发现了两件事,但都不能解决我的用例:

  1. ErrorFragment(关闭,但只有 1 个按钮)

  2. GuidedStepFragment(允许我有多个选项,但需要创建一个单独的 Activity,我必须编写自己的代码才能将选定的选项传递回第一个 Activity)

我觉得我错过了一些东西。这只是普通 Android 应用程序中的几行代码。

我尝试只AlertDialog在我的电视应用程序中使用,但它会引发Theme关于在应用程序上设置不正确的错误。另外,我认为这些对话框无论如何都不是可访问性友好的。

android android-alertdialog leanback

3
推荐指数
1
解决办法
2092
查看次数

在BottomNavigationView上方设置容器布局

我有这个布局。此布局包含BottomNavigationView和嵌套片段的容器

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="client.MainActivity">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

如何app_bar_main在BottomNavigationView上方设置上方?

因为现在:

在此处输入图片说明 BottomNavigationView与交叉

android android-layout

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