一切都适用于com.google.firebase:firebase-core:16.0.4版本,但有一个更新的,当我更新为com.google.firebase:firebase-core:16.0.5gradle然后运行我的应用程序时出现此错误
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\User\AndroidStudioProjects\AppName\app\build\intermediates\transforms\dexBuilder\debug\0.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.google.android.gms.internal.measurement.zzdz
Run Code Online (Sandbox Code Playgroud)
这是我的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.app.test"
vectorDrawables.useSupportLibrary = true
minSdkVersion 17
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} …Run Code Online (Sandbox Code Playgroud) 我试图在其他帖子中找到答案,但我找不到我想要的东西。
我正在构建聊天应用程序,我希望当单击带有聊天消息的 RecyclerView 时键盘消失。
使用下面的代码的简单方法不起作用。
recyclerView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("RecyclerTest", "Clicked");
hideKeyboard();
}
});
Run Code Online (Sandbox Code Playgroud)
我知道如何onClickListener在 RecyclerView 内的项目上实现,但我想知道是否有一种方法可以在整个 RecyclerView 上添加 onClick,或者我应该不打扰并在适配器中的每个项目上添加 onClick,并在任一项目时隐藏键盘被点击了?
编辑:
我的隐藏键盘方法
private void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) ChatRoom.this.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(ChatRoom.this.getCurrentFocus().getWindowToken(), 0);
}
Run Code Online (Sandbox Code Playgroud) 存储聊天消息的最简单方法可能是:
message:
-message1 {
"user1"
"user2"
"message"
"date"
}
-message2
-message3
Run Code Online (Sandbox Code Playgroud)
当应用程序大小增加(大量消息)并且完成数据库操作时,.whereEqualTo以这种方式构造聊天应用程序消息是否有任何缺点?像数据库遍历所有消息一样?
因为如果这种方法存在问题,例如,我已经看过这种结构化数据库的方法,它将在不同的聊天室中隔离消息
chats: {
-chat1 {
"lastMessage"
"timestamp"
"users": {user1, user2}
}
-chat2
-chat3
}
messages: {
-chat1 {
"message"
"date"
}
}
Run Code Online (Sandbox Code Playgroud)
但是在此示例中,添加新消息将需要用户执行2次写入操作,一次写入新消息,以及一次chat使用新的lastMessage和timestamp客户端更新文档,或者chat在添加新消息时创建云功能以使用新值更新文档。
那么,第一个选项是否有效,还是我应该选择类似第二个示例的内容?
我不知道如何将我ImageView的向右移动,现在看起来像这样
我想要这样的东西,所以图像会粘在右边 CardView
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:cardCornerRadius="6dp"
app:cardElevation="6dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
</LinearLayout>
<ImageView
android:id="@+id/imageView3"
android:layout_width="50dp"
android:layout_height="50dp"
app:srcCompat="@mipmap/ic_launcher" />
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud) 我一直在尝试学习libgdx,但是现在我对那里的世界单位有些困惑,我什至不知道我应该问什么确切的问题。
无论如何,我一直在这里阅读示例游戏代码
,据我了解,没有摄像头时,SpriteBatch会渲染与设备分辨率相关的所有内容,因此会产生像素,但是当我们制作摄像头时,先设置其“大小”,位置,然后使用batch.setProjectionMatrix(camera.combined),批量转换像素单元,然后它知道在何处渲染,但在这场比赛中有之间的碰撞检测Rectangle的物体,当你的这个是设置位置Rectangle与rect.set(x, y, 1, 1);其中x和y是世界的单位,而不是像素,请问矩形知道它应该使用那些x和y作为单位,而不是像素,如果没有什么setProjectionMatrix可以让我们知道现在我们正在以单位而不是像素为单位,那么这就是1, 1);最后,它也是单位吗?如果是这样,那么Rectangle如何知道这些单位应该多大(例如游戏中的比例为1/16)renderer = new OrthogonalTiledMapRenderer(map, 1 / 16f);.
我什至不知道这个问题是否真的有道理,但这就是我在这里,我真的在这里迷路了
编辑:好的,我知道单元现在是如何工作的,但是碰撞仍然使我有些困惑,在此示例中,我创建了这个
// onCreate
mapSprite = new Sprite(new Texture(Gdx.files.internal("space.png")));
planetTexture = new Texture(Gdx.files.internal("planet.png"));
shapeRenderer = new ShapeRenderer();
//Planet(X,Y,Radius)
planet = new Planet(20, 30, 7);
planet2 = new Planet(70, 50, 8);
circle = new Circle(planet.getPosition().x + planet.radius, planet.getPosition().y + planet.radius, planet.radius);
circle2 = …Run Code Online (Sandbox Code Playgroud) 到目前为止,我认为onCreateViewHolderinRecyclerView.Adapter是在我用 调用适配器的构造函数时被调用的adapter = new RecyclerViewAdapter(this, list),但我意识到它实际上是onCreate在所有代码执行后在Activity 的方法末尾调用的,这与它有关RecyclerView 不会创建不必要的视图,并且只会创建多少可以适合设备屏幕的视图?
我想用 ObjectAnimator 平移视图两次,但再次按下按钮后“X”位置又回到起始位置,我怎样才能让它继续,并在这种情况下进一步向右移动?
final ObjectAnimator animation = ObjectAnimator.ofFloat(button, "translationX", 100f);
animation.setDuration(2000);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
animation.start();
}
});
Run Code Online (Sandbox Code Playgroud)