小编mat*_*rix的帖子

将 SQL 查询分解为访问内容提供程序的部分

我有一个来自字符串的 SQL 查询并试图访问ContentProvider. sql 查询如下所示:

String query = "SELECT * FROM application_settings WHERE _id = ?";
Run Code Online (Sandbox Code Playgroud)

我必须通过以下方式访问内容提供者ContentResolver

context.getContentResolver().query()
Run Code Online (Sandbox Code Playgroud)

但查询方法接受:

Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder);
Run Code Online (Sandbox Code Playgroud)

有没有办法可以将字符串查询拆分为投影、选择、选择参数和排序顺序?

我不想执行原始查询,所以我更愿意为这个函数提供一个带有绑定值的解决方案。

android android-contentprovider android-sqlite

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

Android Gradle在另一个模块中包含模块依赖项

我正在使用最新的Android Studio 3.0.0-beta6来构建我的Android项目,并且存在此依赖项问题。 Gradle鼓励我compile'simplementation's。这是我的项目结构:

项目:

  • 模块1

    • 模块2

Module1取决于某些库,module2取决于module1。但是,来自module1的库在module2中不可见。我不想复制粘贴依赖项,而是只将库依赖项声明一次。有一个简单的解决方案吗?谢谢。

module1的构建包:

dependencies {
    ....
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    ...
}
Run Code Online (Sandbox Code Playgroud)

module2的构建包:

implementation project(':module1')
Run Code Online (Sandbox Code Playgroud)

dependencies android android-gradle-plugin

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

找不到 androidx.compose.ui.window.MenuBar

我正在尝试使用androidx.compose.ui.window.MenuBarJetbrain教程,但问题是当我尝试在我的项目中使用它时它不会显示。

问题是这样的:

截屏

它只允许我从这两个位置导入,但是当我使用导入时,它不会抱怨或解决错误。

构建.gradle.kts

import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.6.10"
    id("org.jetbrains.compose") version "1.1.0"
}

group = "me.whate"
version = "1.0"

repositories {
    google()
    mavenCentral()
    maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

dependencies {
    implementation(compose.desktop.currentOs)
}

tasks.withType<KotlinCompile>() {
    kotlinOptions.jvmTarget = "11"
}

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "Test"
            packageVersion = "1.0.0"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试过使缓存等失效,但到目前为止没有成功。

有人有什么建议吗?

kotlin android-jetpack-compose

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

在android中可跨文本视图的特定部分设置clicklistener

我在 android中设置ClickListener文本的特定部分时遇到困难SpannableTextView

我有这样的文字:

注册即表示您同意条款和服务

我只想将 clicklistener 设置为粗体部分?是否可以?

android

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

尝试将其锚定在 Coordinatorlayout 中时,ImageView 处于半隐藏状态

当我尝试锚定ImageViewin时,我遇到了一个奇怪的问题AppbarLayout

在设计器中它看起来像这样:

在此处输入图片说明

当我运行应用程序时,它看起来像:

在此处输入图片说明

我的代码:

<?xml version="1.0" encoding="utf-8"?>
<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:descendantFocusability="beforeDescendants"
    android:fitsSystemWindows="true"
    android:focusableInTouchMode="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipChildren="true"
            app:contentScrim="@color/transparent"
            app:layout_scrollFlags="enterAlways">

            <ImageView
                android:id="@+id/banner_image"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:fitsSystemWindows="true"
                android:scaleType="fitXY"
                app:layout_collapseMode="parallax"
                app:srcCompat="@color/blue"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"/>

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <RelativeLayout
        android:id="@+id/signup_screen_form"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <TextView
            android:id="@+id/screen_label"
            android:text="@string/signup"
            android:gravity="center"
            android:textAllCaps="true"
            android:padding="@dimen/screen_label_padding"
            android:layout_alignParentTop="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <com.mypackage.android.views.register.StepIndicatorView
            android:id="@+id/step_indicator"
            android:layout_below="@id/screen_label"
            android:layout_centerHorizontal="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/steps_recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/layout_bottom"
            android:layout_below="@id/step_indicator"/>

        <LinearLayout
            android:id="@id/layout_bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal"
            android:padding="@dimen/bottom_layout_padding">

            <Button …
Run Code Online (Sandbox Code Playgroud)

android android-imageview android-coordinatorlayout

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

Bintray和jCenter并没有真正自动同步他们的更改

我在这里遇到一个奇怪的问题.我将我的Android库上传到Bintray,当我要求添加到jCenter时,一切正常.

图书馆是这样的:

http://jcenter.bintray.com/com/github/kostasdrakonakis/button_preference/1.0.0

所以我可以使用gradle看到这样的东西:

compile 'com.github.kostasdrakonakis:button_preference:1.0.0'
Run Code Online (Sandbox Code Playgroud)

但后来我将工件ID更改为:

而不是button_preference按钮首选项

所以我可以期待类似的东西:

compile 'com.github.kostasdrakonakis:button-preference:1.0.0'
Run Code Online (Sandbox Code Playgroud)

但是因为我看到它是这样的:

https://bintray.com/bintray/jcenter?filterByPkgName=button-preference

但不是在jcenter中:

http://jcenter.bintray.com/com/github/kostasdrakonakis/

有什么建议?

android artifactory gradle bintray jcenter

0
推荐指数
1
解决办法
113
查看次数