我有一个来自字符串的 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 Studio 3.0.0-beta6来构建我的Android项目,并且存在此依赖项问题。
Gradle鼓励我compile's用implementation's。这是我的项目结构:
项目:
模块1
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) 我正在尝试使用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)
我尝试过使缓存等失效,但到目前为止没有成功。
有人有什么建议吗?
我在 android中设置ClickListener文本的特定部分时遇到困难SpannableTextView。
我有这样的文字:
注册即表示您同意条款和服务
我只想将 clicklistener 设置为粗体部分?是否可以?
当我尝试锚定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库上传到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/
有什么建议?