小编pt2*_*121的帖子

状态栏变为白色,并且不显示其背后的内容

我在Marshmallow上尝试AppCompat.我希望有一个透明的状态栏,但它会变成白色.我已经尝试了几个解决方案,但它们对我不起作用(透明状态栏不能使用windowTranslucentNavigation ="false",Lollipop:绘制后面的statusBar,其颜色设置为透明).这是相关的代码.

我的styles.xml

<style name="Bacon" parent="Theme.Bacon"/>

<style name="Theme.Bacon" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/theme_primary</item>
    <item name="colorPrimaryDark">@color/theme_primary_dark</item>
    <item name="colorAccent">@color/theme_accent</item>
    <item name="windowActionBar">false</item>
    <item name="windowActionBarOverlay">true</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowBackground">@color/background_material_light</item>  
</style>

<style name="Theme.Bacon.Detail" parent="Bacon"/>
Run Code Online (Sandbox Code Playgroud)

V21

<style name="Bacon" parent="Theme.Bacon">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

<style name="Theme.Bacon.Detail" parent="Bacon">
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

活动

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

分段

<android.support.design.widget.CoordinatorLayout 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"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginBottom="32dp"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed" …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-support-library androiddesignsupport android-6.0-marshmallow

84
推荐指数
12
解决办法
6万
查看次数

调用需要API级别16(当前最小值为14):android.app.Notification.Builder #build

在此输入图像描述文档说在API级别11中添加了Notification.Builder.为什么我会收到此lint错误?

调用需要API级别16(当前最小值为14):android.app.Notification.Builder #build

notification = new Notification.Builder(ctx)
                .setContentTitle("Title").setContentText("Text")
                .setSmallIcon(R.drawable.ic_launcher).build();
Run Code Online (Sandbox Code Playgroud)

表现:

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" />
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

如果我错了,请纠正我但是在11级添加了API,对吗? 在API级别11中添加

android android-lint

33
推荐指数
3
解决办法
3万
查看次数

在ConstraintLayout中引用的视图消失时保留边距

我有2个TextViews,如下面的xml.如果我textView2在运行时隐藏,我会失去底部边距.textView如果textView2消失,我怎样才能保持底部边距和父节点之间的16dp .

<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content">

  <TextView
      android:id="@+id/textView"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginBottom="16dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:text="abc"
      app:layout_constraintBottom_toTopOf="@+id/textView2"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_chainStyle="packed"
      />

  <TextView
      android:id="@+id/textView2"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginBottom="32dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:text="xyz"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/textView"
      app:layout_constraintVertical_chainStyle="packed"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout

26
推荐指数
2
解决办法
9874
查看次数

为什么我不能编写一般函数来检查两个列表是否相等?

我正在学习Haskell,我不明白为什么我能这样做:

f :: [Int] -> Bool
f l  
    | l==l = True
    | otherwise = False
Run Code Online (Sandbox Code Playgroud)

但我不能这样做.

f :: [a] -> Bool
f l  
    | l==l = True
    | otherwise = False
Run Code Online (Sandbox Code Playgroud)

引擎盖下发生了什么?

haskell

11
推荐指数
1
解决办法
1622
查看次数

如何在IOS 5及以上版本中找到最前端应用的紫色端口?

我正在尝试编写一个在后台运行的应用程序,并为跳板或其他应用程序注入触摸.我知道我将使用私有API和结构.该应用程序是一个企业应用程序,无需批准AppStore.

我正在使用KennyTM建议的GSEvent结构,对IOS 5/6进行一些小修改.我可以通过发送GSSystemEvents将触摸事件和其他事件发送到Springboard.

我需要能够将类似的事件发送到其他应用程序,但我无法找到最前面的应用程序的端口.

有没有办法获得前期和运行的应用程序的端口,以便我可以将我的GSEvents发送到应用程序?

如果有人可以指出我的例子或告诉我如何获得最前端应用程序的紫色端口,那将是很好的.

谢谢!

iphone-privateapi ios

11
推荐指数
1
解决办法
3567
查看次数

Kotlin lambda语法混乱

我对Kotlin lambda语法感到困惑.

起初,我有

.subscribe(
          { println(it) }
          , { println(it.message) }
          , { println("completed") }
      )
Run Code Online (Sandbox Code Playgroud)

哪个工作正常.

然后我将onNext移动到另一个名为GroupRecyclerViewAdapter的类中,该类实现了Action1<ArrayList<Group>>.

.subscribe(
          view.adapter as GroupRecyclerViewAdapter
          , { println(it.message) }
          , { println("completed") }
      )
Run Code Online (Sandbox Code Playgroud)

但是,我得到了错误:

错误

Error:(42, 17) Type mismatch: inferred type is () -> ??? but rx.functions.Action1<kotlin.Throwable!>! was expected
Error:(42, 27) Unresolved reference: it
Error:(43, 17) Type mismatch: inferred type is () -> kotlin.Unit but rx.functions.Action0! was expected
Run Code Online (Sandbox Code Playgroud)

我可以通过更改为:修复错误:

.subscribe(
          view.adapter as GroupRecyclerViewAdapter
          , Action1<kotlin.Throwable> { println(it.message) }
          , Action0 …
Run Code Online (Sandbox Code Playgroud)

kotlin rx-kotlin

11
推荐指数
1
解决办法
3597
查看次数

参考Kotlin中的Java接口静态字段

我可以从Kotlin引用Java接口字段吗?我有这个Java接口:

public interface BaseColumns {
    public static final String _ID = "_id";
    public static final String _COUNT = "_count";
}
Run Code Online (Sandbox Code Playgroud)

我在Kotlin中实现它:

object UserEntry : BaseColumns {
    // some code
}
Run Code Online (Sandbox Code Playgroud)

我尝试时得到Unresolved引用UserEntry._ID.我该如何访问_ID?我错过了什么吗?谢谢!

kotlin

11
推荐指数
1
解决办法
928
查看次数

mobileNetworkCode返回"VZW"而不是数字移动网络代码

我试过这段代码:

CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
if(carrier != nil)
{
    NSString *mnc = [carrier mobileNetworkCode];
    NSLog(@" mnc is %@ ", mnc);
}
Run Code Online (Sandbox Code Playgroud)

当运营商是AT&T时,它的工作正如我预期的那样.我的mnc是410.

但是,当运营商是Verizon时.我得到了"mnc is VZW". 这是API的正确行为吗?我能获得数字移动网络代码的任何其他方式吗?

注意:Apple的文档说该方法应该返回...

一个只读NSString对象,表示用户的蜂窝服务提供商的数字移动网络代码.

我不确定我做错了什么或者我的手机出了什么问题:-)

iphone ios

9
推荐指数
1
解决办法
375
查看次数

即使设置了最高优先级并首先安装,也不会获取短信

安装Go SMS时,我的应用程序不会收到短信.我设置了最高优先级,并在安装Go SMS应用程序之前尝试安装我的应用程序.但是,Go SMS总是在我之前收到短信.(第一个应用程序安装的概念在我的手机上不起作用.)

我很好奇Go SMS开发人员做了什么.他们的应用程序如何在我之前始终拦截短信?

没有Go SMS,我的应用程序工作正常.无论如何,这是我的清单.也许我做错了什么.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.ansmsreceiver"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.test.ansmsreceiver.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <receiver android:name="com.test.ansmsreceiver.SMSReceiver" >
        <intent-filter android:priority="2147483647">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            <action android:name="android.provider.Telephony.NEW_OUTGOING_SMS" />
        </intent-filter>
    </receiver>
</application>
Run Code Online (Sandbox Code Playgroud)

我发现了与我的问题有关的其他问题,但仍无法找到解决问题的方法.

编辑:我的测试项目在Github上:https://github.com/entryleveldev/ansmsreceiver.

Edit2:仍然不确定android如何决定哪个接收者首先获得意图.根据我的测试,Go SMS总是得到意图.UID和安装顺序无关紧要.但是当我测试我的应用程序和Handcent SMS时,安装顺序很重要.也许Go SMS使用某种hacky方式来做到这一点.

这是Go SMS清单中的SmsReceiver.

<receiver android:name=".smspopup.SmsReceiver" android:permission="android.permission.BROADCAST_SMS">
        <intent-filter android:priority="2147483647">
            <action android:name="android.provider.Telephony.SMS_RECEIVED"></action> …
Run Code Online (Sandbox Code Playgroud)

android android-intent

8
推荐指数
1
解决办法
3071
查看次数

一切都是Scala中的一个对象

我是Scala的新手并且听到很多东西都是Scala中的一个对象.我不知道的是"一切都是对象"的优势是什么?如果一切都不是对象,我不能做的事情是什么?欢迎举例.谢谢

scala

7
推荐指数
1
解决办法
1296
查看次数