一个非常基本的问题,在Kotlin中连接String的正确方法是什么?
在Java中,您将使用该concat()
方法,例如
String a = "Hello ";
String b = a.concat("World"); // b = Hello World
Run Code Online (Sandbox Code Playgroud)
但该concat()
功能不适用于Kotlin.我应该使用这个+
标志吗?
是否有可能将谷歌助手集成到Android应用程序中?
我在网上找不到任何关于它的信息.
我知道今天谷歌发布了助手SDK,但即使在他们的Android开发者博客帖子中他们也没有提到任何Android支持
如果安装了应用程序可以提供的内容,这将是有用的.
例如:
"好的谷歌,在亚马逊上找到星球大战蓝光"
它将启动亚马逊购物应用程序并寻找它.
是否可以使用此发布的SDK在应用程序中实现类似的功能?
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.CacheControl$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Request$Builder
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Call
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Response
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.ResponseBody
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:com.squareup.picasso.OkHttpDownloader: can't …
Run Code Online (Sandbox Code Playgroud) 在Kotlin中,我将覆盖这两个Google登录功能:
override fun onConnectionFailed(result: ConnectionResult) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE)
} catch (e: IntentSender.SendIntentException) {
// Unable to resolve, message user appropriately
}
} else {
val gaa = GoogleApiAvailability.getInstance()
gaa.getErrorDialog(this, result.errorCode, 0)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
when (requestCode) {
RESOLVE_CONNECTION_REQUEST_CODE -> if (resultCode == Activity.RESULT_OK) {
mGoogleApiClient!!.connect()
}
}
}
Run Code Online (Sandbox Code Playgroud)
检查与谷歌的连接是否失败.
问题是,有时,当我关闭包含用户帐户的对话框时,会在启动活动时弹出该对话框
像这个:
我正在IllegalArgumentException
使用以下logcat
E/AndroidRuntime:FATAL EXCEPTION:main进程:com.dancam.subscriptions,PID:6346 java.lang.RuntimeException:将结果ResultInfo {who = null,request = 6783,result = 0,data = null}传递给activity {失败.dancam.subscriptions/com.dancam.subscriptions.ActiveSubscriptions.Subscriptions_main}:java.lang.IllegalArgumentException:指定为非null的参数为null:方法kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull,android.app.ActivityThread中的参数数据.deliverResults(ActivityThread.java:4126)在android.app.ActivityThread.handleSendResult(ActivityThread.java:4169)的android.app.ActivityThread.-wrap20(ActivityThread.java)android.app.ActivityThread …
渲染问题无法解析资源@id/search_edit_frame
这是我在xml文件中得到的渲染错误.我认为它与我的support.v7.SearchView
下面有关系是我的xml:
<RelativeLayout
android:id="@+id/layout_ricerca"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/search_border_backgroud"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="20dp">
<android.support.v7.widget.SearchView
android:id="@+id/testo_ricerca"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:queryHint="@string/search_hint"
android:textSize="25sp"
android:layout_marginStart="5dp"
android:iconifiedByDefault="false"/>
<ImageButton
android:id="@+id/tasto_ricerca"
android:background="@color/trans"
android:layout_marginTop="2dp"
android:layout_width="45dp"
android:layout_height="match_parent"
android:layout_marginEnd="3dp"
android:scaleType="centerInside"
android:layout_alignParentEnd="true"
android:src="@drawable/tasto_ricerca"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
当我改变了<android.support.v7.widget.SearchView
对<SearchView
错误消失,但是这不是一个很好的解决方案适合我,因为我不得不改变我所有的Java代码与合作SearchView
,而不是android.support.v7.widget.SearchView
.
有谁知道如何解决这个问题?为什么会这样?我不认为我的xml有什么问题.
编辑:
添加了错误的屏幕截图
我为我的RecyclerView设置了一个ItemClickLister,如下所示:
ItemClickSupport.addTo(recyclerView!!).setOnItemClickListener(
object : ItemClickSupport.OnItemClickListener {
override fun onItemClicked(recyclerView: RecyclerView?, position: Int, v: View?) {
val row = recyclerView!!.getChildAt(position)
val el = row.findViewById(R.id.active_expandablelayout) as ExpandableLayout
if (el.isExpanded) {
el.collapse()
} else {
el.expand()
}
}
}
)
Run Code Online (Sandbox Code Playgroud)
使用我翻译成Kotlin的ItemClickSupport库.
我在object
(第2行)上收到错误消息:
object必须声明为abstract或实现抽象成员.
我是Kotlin的新手,我也找不到任何解决方案.
任何帮助是极大的赞赏.
编辑:
这是我的ItemClickSupport.kt
:
class ItemClickSupport private constructor(private val mRecyclerView: RecyclerView) {
private var mOnItemClickListener: OnItemClickListener? = null
private var mOnItemLongClickListener: OnItemLongClickListener? = null
private val mOnClickListener = View.OnClickListener { v ->
if (mOnItemClickListener != null) …
Run Code Online (Sandbox Code Playgroud) 我一直在nougat上开发一个应用程序,它在外部存储中创建一个目录.
我过去常常这样做:
final File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Chords/Processed Audio");
dir.mkdirs();
Run Code Online (Sandbox Code Playgroud)
此代码似乎不适用于API 26(Android Oreo).目录未创建.
我怎样才能实现相同的功能,最好适用于从API 21到API 26的所有Android版本?
尝试在发布模式下构建应用程序时遇到此错误。
错误:属性签名需要InnerClasses属性。检查-keepattributes指令
我的proguard-rules.pro
行看起来像这样:
-keepattributes Signature
Run Code Online (Sandbox Code Playgroud)
编译器指的是什么InnerClasses?我要省略什么?
For my App I need to have a List sync with Google Drive. I have already implemented the SignIn and had my Main_Activity implement both:
com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks,
com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener
Run Code Online (Sandbox Code Playgroud)
Even though I read the whole Google Drive API for Android documentation, and more specifically the Store Application Data part. And looked through the example on GitHub, I wasn't able to get it to work. I personally think that this documentation is really confusing to read. It's not even clear what is …
我需要画这样的东西:
我尝试通过创建 aCustomClipper<Path>
并在 a 中使用它来做到这一点ClipPath()
这是我的代码:
class ArcBackground extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipPath(
child: Container(
width: double.infinity,
height: 400.0,
color: Colors.orange,
),
clipper: RoundedClipper(),
);
}
}
class RoundedClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0.0, size.height);
path.quadraticBezierTo(
size.width / 2,
size.height - 100,
size.width,
size.height
);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
Run Code Online (Sandbox Code Playgroud)
这段代码给了我以下输出:
正如您所看到的,弧指向上是因为我将quadraticaBezierTo()
y1
属性设置为size.height …