Tag: 安卓

错误:链接引用失败。 – > QueuedJob

我正在研究使用Kotlin的Android材质设计,一切都很好,直到我尝试使用android.support.design.widget.FloatingActionButton。 当我重建项目时,我得到了下面的错误信息: Information:Gradle tasks [clean, :app:assembleDebug] C:\Users\qin\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\3d5ddc383685b19d22429a29e09f2aeb\res\values\values.xml Error:(1419, 5) error: style attribute ‘attr/textColor (aka br.com.conseng.themedesign:attr/textColor)’ not found. Error:(1525, 5) error: style attribute ‘attr/textColor (aka br.com.conseng.themedesign:attr/textColor)’ not found. …..\CursoMaterialDesign\ThemeDesign\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml Error:(1843) style attribute ‘attr/textColor (aka br.com.conseng.themedesign:attr/textColor)’ not found. Error:(1953) style attribute ‘attr/textColor (aka br.com.conseng.themedesign:attr/textColor)’ not found. Error:failed linking references. Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for […]

Android工作室3.0.1:执行失败的任务’应用程序:processDebugGoogleServices’

朋友们,我最近开始在Android上工作,如果你发现一些基本的错误,请原谅。 这是我的问题。 我试图从过去的两天解决问题,但没有取得任何成功。 最近,我已经升级我的Android工作室到3.0.1,并试图编译我的项目,但我面临以下错误 错误:执行任务’:app:processDebugGoogleServices’失败。 请通过更新google-services插件的版本来修复版本冲突(有关最新版本的信息, 请访问https://bintray.com/android/android-tools/com.google.gms.google-services/ )或将com.google.android.gms的版本更新为11.0.0。 请检查我的build.gradle apply plugin: ‘com.android.application’ apply plugin: ‘kotlin-android’ apply plugin: ‘kotlin-android-extensions’ dependencies { implementation ‘com.google.firebase:firebase-messaging:11.0.0’ compile fileTree(include: [‘*.jar’], dir: ‘libs’) testCompile ‘junit:junit:4.12’ //adding volley library //Picasso compile “org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version” compile ‘com.android.volley:volley:1.0.0’ compile ‘com.squareup.picasso:picasso:2.5.2’ compile ‘com.google.gms:google-services:3.1.2’ // compile ‘com.google.gms:google-services:3.1.1’ compile ‘com.google.android.gms:play-services:11.0.0’ compile ‘com.android.support:appcompat-v7:25.2.0’ compile ‘com.android.support:design:25.2.0’ compile ‘com.google.android.gms:play-services-ads:11.0.0’ compile ‘com.google.firebase:firebase-core:10.0.1’ compile […]

检测EditText上的触摸,但不会中断它?

我需要知道用户在我的活动中触摸/点击/点击edittext。 我怎样才能做到这一点,而不中断的事件,所以键盘仍然显示正确? (我需要了解它之前,操作系统显示键盘…如果可能的话)

Android系统。 设置textSize所以它的高度匹配它的父布局高度的百分比 – 可能吗?

我的任务很简单,但任何解决方案似乎非常复杂…我有一个应用程序,动态生成每行textView / editText 17表。 现在textSize被硬编码为20f所有textViews / editText – 它看起来不错,在我的手机,但它不是很兼容的FX。 平板电脑。 我想将文本大小设置为一个数字,它将使外部容器的文本的高度为1/17。 无论设备具有多大的尺寸/分辨率,每个tableRow都可以完美地适应屏幕。 它如何看起来不同的scrren大小 – img 它应该如何看起来不同的尺寸 – img 而不管别的什么样的屏幕; 英寸,尺寸,分辨率等等,文本行高总应该是红框高度的1/17。 这甚至有可能吗? 我写在kotlin和我的用户界面是动态生成的,我创建像这样的行和textViews: fun createRow(label: String, tf: Typeface): TableRow { val row = TableRow(activity) row.setBackgroundResource(R.drawable.border) gameSheetTable.addView(row) val tw = TextView(activity) tw.text = label tw.textSize = textSize tw.typeface = tf tw.setTextColor(Color.BLACK) textViews.add(tw) row.addView(tw) return row } 我努力了: […]

带参数的单身人士在Kotlin

我正在尝试将Android应用程序从Java转换为Kotlin。 应用程序中有几个单身人士。 我没有构造函数参数的单身人士使用伴侣对象。 还有另外一个单例需要一个构造函数参数。 Java代码: public class TasksLocalDataSource implements TasksDataSource { private static TasksLocalDataSource INSTANCE; private TasksDbHelper mDbHelper; // Prevent direct instantiation. private TasksLocalDataSource(@NonNull Context context) { checkNotNull(context); mDbHelper = new TasksDbHelper(context); } public static TasksLocalDataSource getInstance(@NonNull Context context) { if (INSTANCE == null) { INSTANCE = new TasksLocalDataSource(context); } return INSTANCE; } } 我在kotlin的解决方案: […]

我不能在Kotlin的活动之间进行联系

你好,这是我的第一个应用程序kotlin我想使年度费率计算应用程序的问题是我有4个活动每个活动自己的按钮和编辑的文本我不想当用户单击按钮,程序从编辑的文本中获取数字并且只进行计算并将其保存在活动2和3的某处和相同的工作中,但是当他单击最后一个活动的最后一个按钮时,我想要调用所有结果并在ViewText中显示它 问题是:如何保存数据每当有需要的时候打电话给我? 第一个活动 class st { var int_P: Double? = null var ctl_P: Double? = null public constructor(int_P: Any, ctl_P: Any) { this.int_P = int_P.toString().toDouble() //Physique this.ctl_P = ctl_P.toString().toDouble() public fun GetMP(): Double { return (this.int_P!! + (this.ctl_P!! * 2)) / 3 } } Btn_Next1.setOnClickListener ({ var int_P = java.lang.Double.parseDouble(edit_IP.text.toString()) //Physique var ctl_P = java.lang.Double.parseDouble(edit_CP.text.toString()) […]

为什么添加谷歌的火力点引起Dex错误?

添加 实现“com.google.firebase:firebase-core:11.8.0” 到我的模块gradle文件给我错误提示我有超过64K方法在我的项目。 我的猜测是,我以某种方式实现了整个谷歌播放服务,虽然增加 实现’com.google.android.gms:play-services-maps:11.8.0′ 要么 实现’com.google.android.gms:play-services-location:11.8.0′ 给我没有错误。 格拉德尔: apply plugin: ‘com.android.application’ apply plugin: ‘kotlin-android’ apply plugin: ‘kotlin-android-extensions’ android { compileSdkVersion 26 buildToolsVersion “26.0.2” defaultConfig { applicationId “se.workshop.collect” minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName “1.0” testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” vectorDrawables.useSupportLibrary = true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’ } } } dependencies […]

内联setter或不在Kotlin中创建未使用的setter?

我注意到Kotlin为var创建setter ,并通过setter来设置值,而不是直接设置。 我们可以让内线 ? 或者直接设置值而不创建默认的私有setter方法? lateinit var name: String private set

如何使用Kotlin设置OnEditorActionListener

所以我有这个Java代码: editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { doSomething(); return true; } return false; } }); 我已经设法得到这(我甚至不知道这是正确的方式): editText.setOnEditorActionListener() { v, actionId, event -> if(actionId == EditorInfo.IME_ACTION_DONE){ doSomething() } else { } } 但我得到一个错误Error:(26, 8) Type mismatch: inferred type is kotlin.Unit but kotlin.Boolean was expected […]

更好的方式来格式货币输入editText?

我有一个editText,起始值是$ 0.00。 当您按1时,它将更改为$ 0.01。 按4,到$ 0.14。 按8,$ 1.48。 按退格键,$ 0.14等 这是有效的,问题是,如果有人手动定位光标,格式化会出现问题。 如果他们要删除小数,它不会回来。 如果他们把光标放在小数点前面并输入2,它将显示$ 02.00而不是$ 2.00。 如果他们试图删除$,它将删除一个数字,例如。 这里是我正在使用的代码,我会很感激任何建议。 mEditPrice.setRawInputType(Configuration.KEYBOARD_12KEY); public void priceClick(View view) { mEditPrice.addTextChangedListener(new TextWatcher(){ DecimalFormat dec = new DecimalFormat(“0.00”); @Override public void afterTextChanged(Editable arg0) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, […]