小编Mic*_*odd的帖子

气流 - 上次运行不正确

我刚刚运行了一个气流 DAG。当我看到气流上次运行日期时,它显示最后但最后一次运行日期。当我将鼠标悬停在“i”图标上时,它引起了我的注意,它显示了正确的日期。有什么办法可以解决这个问题吗?听起来像是无稽之谈,但我最终用它来对我的数据进行质量检查。

在此输入图像描述

airflow airflow-scheduler

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

如何在Java代码中找到空的catch块

有没有办法在Java代码中找到所有空的catch块?我知道有一些像PMD这样的工具可以做到这一点,但我使用的是RSA.我们有什么方法可以编写正则表达式来搜索空的catch块吗?

我正在使用公司机器,我无法安装新软件.

java

5
推荐指数
2
解决办法
3335
查看次数

5
推荐指数
1
解决办法
991
查看次数

Fragment中的自定义ListView不遵循父主题

我目前在使用Holo.Light主题的自定义ListView适配器时遇到问题.在活动和片段中,任何TextView都显示在主题的常规颜色(textColorPrimary)中.但是,自定义ListAdapter中的任何文本都使用textColorPrimary默认的Holo主题,从而有效地使文本不可读.

以下是我应用主菜单中的示例:


list_main_menu.xml - ListAdapter的行布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/imgIcon"
        android:layout_height="48dip"
        android:layout_width="48dip"
        android:src="@drawable/ic_launcher"
        />

    <TextView 
        android:id="@+id/txtFirstLine"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/imgIcon"
        android:text="Line 1"
        android:textSize="12pt"
        />

    <TextView
        android:id="@+id/txtSecondLine"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/imgIcon"
        android:layout_below="@id/txtFirstLine"
        android:text="Line 2"
        />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

注意:我目前不得不android:textColor="?android:attr/textColorPrimaryInverse"用来使文本可读.


fragment_main_menu.xml - 主菜单片段.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical" >
    <TextView
        android:id="@+id/txtWelcome"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Username"
        android:textSize="18sp"
        />
    <ListView
        android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />     
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

AndroidManifext.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.michaeldodd.treasurehunter" …
Run Code Online (Sandbox Code Playgroud)

android android-listview android-theme

4
推荐指数
1
解决办法
4616
查看次数

设置Android Studio以脱机工作

我在没有互联网连接的地方工作.我想使用Android Studio开发Android应用程序,但对于Gradle构建,它需要互联网连接.有没有办法让我可以完全设置Android Studio脱机工作?

我已经在Stack Overflow上尝试过很多答案,但都没有效果.另外,建议我使用其他方法让Android应用程序完全脱机.

android offline offline-caching android-studio

4
推荐指数
1
解决办法
220
查看次数

如何使用 android studio 在 kotlin 代码中添加 try/catch?

使用 android studio 时,我必须在我的 kotlin 代码中添加 try/catch,但不明白如何添加。下面是我必须添加 try/catch 的代码。

我还没有尝试任何东西,因为我完全困惑在哪里应用 try/catch。

1.

class SmsReceiver : BroadcastReceiver(){
    override fun onReceive(context: Context?, intent: Intent) {

        val extras = intent.extras

        if(extras != null){

            val sms: Array<Any> = extras.getString("pdus") as Array<Any>

            for(i in sms.indices){
                val format = extras.getString("format")

                var smsMessage = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
                    SmsMessage.createFromPdu(sms[i] as ByteArray,format)
                }else{
                    SmsMessage.createFromPdu(sms[i] as ByteArray)
                }

                var phoneNumber = smsMessage.originatingAddress
                val messageText = smsMessage.messageBody.toString()

                Toast.makeText(context,"$phoneNumber:(Private)\n" + "messageText: $messageText",Toast.LENGTH_SHORT).show()
            }
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

2.

class MainActivity :AppCompatActivity(){

    private val …
Run Code Online (Sandbox Code Playgroud)

android try-catch kotlin

4
推荐指数
1
解决办法
3095
查看次数

如何为钢琴创建布局

我正在研究钢琴应用程序,我在布局创建方面遇到了一些问题.我想创建一个如下所示的布局:

在此输入图像描述

但我只能创造这个

在此输入图像描述

现在我想添加所有黑色按钮,但问题是我无法在这些按钮上方添加视图.我怎样才能做到这一点?我目前的布局代码如下,请建议我如何实现这一目标.现在我可以点击所有按钮,一旦我添加了所有按钮,那么每个按钮都应该是可点击的.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/relativeLayout2"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:weightSum="1.5" >

        <ImageView
            android:id="@+id/bw1"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw2"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw3"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw4"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw5"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw6"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw7"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw8"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight=".1"
            android:background="@drawable/blacknew" />

        <ImageView
            android:id="@+id/bw9"
            android:layout_width="0dip"
            android:layout_height="match_parent" …
Run Code Online (Sandbox Code Playgroud)

layout android

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

IllegalStateException - Fragment.getResources

在我的片段中,我在很多地方使用资源字符串。理想情况下,一切正常。

但是,我经常收到崩溃报告IllegalStateException说 Fragment 没有附加到活动。我可以想象的一种可能的解决方案是使用isAdded()返回片段是否附加到活动的方法,但是在访问字符串资源之前在所有地方使用它对我来说似乎不是正确的解决方案,因为它可能会破坏流程。

另外,我可以使用以下实现吗,不确定它是否正确?初始化mActivity的onAttach片段,然后用它来获得资源字符串。

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof Activity) {
        mActivity = (Activity) context;
    }
}
Run Code Online (Sandbox Code Playgroud)

代替

 getString(R.string.string_resource)
Run Code Online (Sandbox Code Playgroud)

用

mActivity.getString(R.string.string_resource)
Run Code Online (Sandbox Code Playgroud)

我可以放心,使用它会停止IllegalStateExceptions吗?

android android-fragments android-activity android-fragmentactivity

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

应用程序可能在其主线程上做了太多工作。如何修复它

当我从缓存中获取大量数据(以视频形式)时,应用程序会在很长的延迟后响应。我该如何解决或修复它?

日志猫。 应用程序可能在其主线程上做了太多工作

java android

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

错误:无法添加任务“干净”,因为该名称的任务已经存在

从Gradle进行构建时,我遇到了问题。这是我面临的错误:

错误:无法添加任务“干净”,因为具有该名称的任务已经存在。

这是我的摇篮

apply plugin: 'com.android.application'android {
compileSdkVersion 28
buildToolsVersion "25.0.1"
defaultConfig {
    applicationId "net.accedegh.retrofitlibrary"
    minSdkVersion 17
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:recyclerview-v7:28.0.0"
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.picasso:picasso:2.4.0'
implementation 'com.github.jd-alexander:LikeButton:0.2.0'
implementation'com.github.bumptech.glide:glide:3.7.0'compile 'com.github.varunest:sparkbutton:1.0.3'
implementation 'com.android.support:design:28.0.0'
androidTestCompile 'junit:junit:4.12'}
Run Code Online (Sandbox Code Playgroud)

顶级build.gradle文件

// Top-level build file …
Run Code Online (Sandbox Code Playgroud)

java android android-gradle-plugin retrofit

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