Tag: 安卓

无法解析:com.google.firebase:firebase-auth:11.0.2

我只是更新SDK,谷歌播放服务和谷歌存储库,但仍然发生这种错误。 请帮助,我想要使用电话号码进行身份验证。 SDK管理器 logcat的 Build.gradle模块:Project // Top-level build file where you can add configuration options common to all sub-projects/module return buildscript { ext.kotlin_version = '1.1.3-2' repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:3.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files […]

Android Studio 3.0会添加参数提示信息吗?

下面的示例代码由Kotlin fun detailIntent.putExtra("Person", SampleData.BOB)在Android Studio 3.0中显示,我发现fun detailIntent.putExtra("Person", SampleData.BOB)显示为detailIntent.putExtra(name: "Person", SampleData.BOB)和I不能在编辑器中删除name 。 看来,Android Studio 3.0添加参数提示信息的名称,对不对? 以及如何设置打开或关闭它?

如何注入瞬间依赖工厂与Kodein?

我想使用ViewModelProvider工厂从意图(即:俱乐部)注入自定义parcelable数据。 val teamModule = Kodein.Module { bind<ViewModelProvider.Factory>("team-factory") with factory { club: Club -> TeamListViewModelFactory(club, instance()) } bind<GetTeams>() with provider { GetTeams(instance()) } bind<TeamRepository>() with provider { TeamDataRepository(instance()) } bind<TeamListViewModel>() with factory { context: FragmentActivity -> ViewModelProviders.of(context, instance("team-factory")).get(TeamListViewModel::class.java) } } 在我的活动中,我想从内置的意图数据获取一个viewModel。在这里我的活动: class TeamActivity : AppCompatActivity(), KodeinInjected { override val injector = KodeinInjector() private val viewModel: TeamListViewModel […]

Android Koltin将微调值传递给可变列表

我有一个微调包含几个项目的应用程序。 我创造了这一切 任何人都可以给我一个例子,我可以如何将这些值传递给我有一个列表? 使用mutableList? 干杯 class NewKitListActivity : AppCompatActivity() { var spinnerArray = arrayOf("Dumbell", "Punching Bag", "Yoga Ball", "Skipping Rope") val kitMutableList = mutableListOf(spinnerArray) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_new_kit_list) val spinner = newKitItemSpinner val spinnerArrayAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, spinnerArray) //selected item will look like a spinner set from XML spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) spinner.adapter = spinnerArrayAdapter […]

如何用copyToRealm插入对象RealmList

我尝试将RealmList对象插入到领域数据库 模型数据类 open class Data : RealmObject() { @SerializedName("Settings") var settings: Settings? = null @SerializedName("Item") var items: RealmList<Items>? = null } fun insert(data: Data) { mRealm.executeTransactionAsync( Realm.Transaction { realm -> val mData = realm.createObject(Data::class.java) mData.settings = data.settings }, Realm.Transaction.OnSuccess { Log.e("setting", "success") } ) } 但它的错误值不是一个有效的管理对象。 然后我从这个链接https://github.com/realm/realm-java/issues/5238找到解决方案 fun insert(data: Data) { mRealm.executeTransactionAsync( Realm.Transaction { realm […]

当CollapsingToolbarLayout展开时,使菜单项透明

我按照这个指南来创建一个折叠的工具栏,你可以在页面上看到。 如您所见,当您向上滚动时,实际工具栏的标题因以下代码而消失: val collapsingToolbarLayout = layout.findViewById<CollapsingToolbarLayout>(R.id.collapsing_toolbar) collapsingToolbarLayout.setExpandedTitleColor(android.R.color.transparent) 我的问题是,我的项目中的工具栏是完全一样的,但也有一个菜单,有几个图标。 当我向上滚动图标仍然在那里,掩盖了图像。 有没有直接的方式来使菜单项的图标不可见和不可点击来解决这个问题? 谢谢

我的模型更改时如何重绘Anko frameLayout?

我有一个Anko组件 ,在这里我创建了一些代码,如下所示: override fun createView(ui: AnkoContext<T>) = with(ui) { frameLayout { var imgView = imageView(R.drawable.ic_1).lparams { horizontalMargin = … topMargin = … width = … height = … } imgView.backgroundColor = gameModel.colour } } 我的imgView的背景取决于我的模型中的颜色。 让我们想象我在其他地方更新我的模型。 如何“刷新”Anko组件UI以反映新的gameModel.colour ? 我从来没有做过任何Android之前,但似乎通常会使用invalidate()或requestLayout()但他们似乎并没有工作。

为什么使用DrawerLayout给IllegalArgumentException:DrawerLayout必须用MeasureSpec.EXACTLY

以下是我的xml: <?xml version="1.0" encoding="utf-8"?> <layout> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root_drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="tailamade.boop.CustomerHomeActivity" tools:openDrawer="start"> <include layout="@layout/content_customer_home" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/navigationView" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/activity_main" app:menu="@menu/menu_customer_home" /> </android.support.v4.widget.DrawerLayout> </layout> 我也尝试编写我自己的CustomDrawerLayout像这样(没有运气): class CustomDrawerLayout : DrawerLayout { constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, […]

Android体系结构组件房间ViewModel CompleteableFormAction

所以我想我会尝试一个小方面的项目。 我跟随了Florina Muntenescu的示例项目: android-architecture-components 我特别注意类: UserActivity.kt , UserViewModel.kt , UserDao.kt UserViewModel#updateUserName()返回一个Completable ,并且必须订阅返回onComplete或onError 当我尝试把viewModel.updateUserName(userName)等价物放入一个RxBindings链。 如果我通常订阅我通过了Disposable! 在最后的.subscribe其值"DISPOSED" 问题是这不会发出一个错误 ,因此永远不知道是否有问题 我怎么能适应下面的代码,以便最终的.subscribe会返回正确的事件? RxTextView.textChanges(editText) .debounce(250L, TimeUnit.MILLISECONDS, schedulers.main) .subscribeOn(schedulers.main) .observeOn(schedulers.disk) .map({ name -> viewModel.updateUserName(name) .subscribe( { Timber.d(“Success”) }, { error -> Timber.d(error, “something went wrong”)) }) }) .observeOn(schedulers.main) .subscribe( { Timber.d("name changed $it}") }, { Timber.e(it, "name error") }) 提前致谢 M.

在espresso测试中“无法启动活动”

这是我的完整代码 ,当我测试下面的代码与“Android测试”,它会引发错误“无法启动活动” //TestPlayer.kt public class PlayerTest : ActivityInstrumentationTestCase2<Player>(Player::class.java) { override fun setUp() { super.setUp() getActivity() } fun testPlayer() { onView(withId(R.id.player)).perform(doubleClick()) } } 我没有在Android显示器中找到任何输出,如何调试?