我的申请有评级栏.我想设置评级栏是不可点击和不可触摸的.为此,我在xml每个评级栏的文件中添加了以下代码.
它在三星galaxy Apollo GT-i5801中工作.但它不适用于HTC手机.为什么?
xml代码
android:clickable="false"
android:focusableInTouchMode="false"
android:focusable="false"
Run Code Online (Sandbox Code Playgroud)
谢谢
我使用ConstraintLayout制作一些简单的应用程序进行测试.但我有一些问题.
这是我的代码
activity_main.xml中
<?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">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.user.myapplication.activity.MainActivity">
<Button
android:id="@+id/btn_launch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="16dp"
android:text="launch"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/text_view"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:text="Hello World!"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_launch" />
<include
layout="@layout/content_main"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_view" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
content_main.xml
<?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">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="123456"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="98765"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" …Run Code Online (Sandbox Code Playgroud) 我正在我的应用程序中使用此权限,并且在所有设备和Marhshmallow 6.0设备中都可以正常工作。
不需要WAKE_LOCK许可运行时,因为它的正常许可但在Nougat 7.0设备中出现问题。
应用程序崩溃并"java.lang.SecurityException: Neither user 10799 nor current process has android.permission.WAKE_LOCK"在线发生错误wakelock.acquire();
如何解决?
我已将 Pdf 文件上传到 firebase 存储,将 pdf 文件上传到 firebase 存储后,我得到了下载网址。现在我想在我的应用程序中打开此下载网址中的 pdf 文件。
以下是我将 pdf 文件上传到 firebase 存储后得到的 url。
现在我想打开一个意图来查看此 pdf 文件,我为此使用了以下代码:
String url = "https://firebasestorage.googleapis.com/v0/b/realtime-chat-46f4c.appspot.com/o/documents%2Fbf307aa5-79ae-4532-8128-ee394537b357.pdf?alt=media&token=2d0c5329-4717-4adc-9418-6614913e5bfa";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "application/pdf");
startActivity(Intent.createChooser(intent, "Choose an Application:"));
Run Code Online (Sandbox Code Playgroud)
我的手机有可以打开此 pdf 文件的应用程序,但它仍然显示没有安装可查看此文件的应用程序。
如果我在文件中转换此 url 并使用以下代码,则应用程序的选择器将打开,但会出现无法打开文件的错误。
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
File file = new File(name);
intent.setDataAndType(Uri.fromFile(file), "aplication/pdf");
Run Code Online (Sandbox Code Playgroud)
我看到很多答案都说先下载文件然后打开它,但我不想下载文件,我只想查看它。
如果有人对此有任何想法,请帮助我。
非常感谢。
更新到最新版本的支持库(27.1.1 -> 28.0.0)后,用户界面出现问题。
tab_layout_unselected_indicator.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-5dp"
android:right="-5dp"
android:top="-5dp">
<shape>
<stroke
android:width="2dp"
android:color="@color/colorGrey" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
选项卡布局:
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorBlackDark"
android:theme="@style/AppTheme.AppBarOverlay"
app:tabBackground="@drawable/tab_layout_unselected_indicator"
app:tabIndicatorColor="@color/colorOrange"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/colorOrange"
app:tabTextAppearance="@style/StrikeCustomTabText"
app:tabTextColor="@color/colorGrey" />
Run Code Online (Sandbox Code Playgroud)
看起来一个标签的背景与另一个交叉。我试图改变缩进并注意到了这一点。现在我使用的是以前版本的支持库 (27.1.1)。如何为当前版本的支持库 (28.0.0) 修复此问题?
我还是完全不明白内存泄漏.我用static方法创建了自定义单例:
public static AnalyticsHelper getInstance(Context context) {
return analyticsHelper == null ?
analyticsHelper = new AnalyticsHelper(FirebaseAnalytics.getInstance(context)) :
analyticsHelper;
}
Run Code Online (Sandbox Code Playgroud)
我想知道如果我实例化它是否会发生内存(活动)泄漏Activity.我不确定,因为其他Firebase工具在实例化时起作用ContentProvider和不需要Context.官方文件对我没有帮助.