Tag: 按钮

libgdx button up down没有效果

val playTexture = assetManager?.get(A.image.gamePlayBtn, Texture::class.java) val skin: Skin = Skin() skin.add("up", TextureRegion(playTexture, 0, 0, 296, 96)) skin.add("down", TextureRegion(playTexture, 0, 96, 296, 96)) val playButton: ImageTextButton = ImageTextButton("PLAY THE GAME", with(ImageTextButton.ImageTextButtonStyle()) { up = skin.getDrawable("up") down = skin.getDrawable("down") font = BitmapFont() font.data.setScale(3f) font.color = Color.ORANGE this }) OnClick事件工作正常,但没有onClicked状态的按钮背景变化(向下)。 我哪里错了?

在Android中委派点击监听器

比方说,我有几个按钮,他们的点击是由一个共同的处理程序处理有没有一种方法来定义监听一次,而不是定义每个按钮的onClick属性? <Button android:onClick="handler" /> 也许父母代表在浏览器或一些拦截器…..想象你有50个按钮,你声明每个明确点击每个?

Facebook信息不显示

我正在尝试使用此代码获取用户信息,但未在活动中显示配置文件图片和名称未在基础上创建新用户 我错过了什么? 有没有人使用Kotlin编码? private fun handleFacebookAccessToken(token: AccessToken) { Log.d(TAG, "handleFacebookAccessToken:" + token) val credential = FacebookAuthProvider.getCredential(token.token) App.currentAuth.signInWithCredential(credential) .addOnCompleteListener(this) { Log.d(TAG, "signInWithCredential:success") } .addOnSuccessListener(this) { authResult -> if (authResult != null) { val firebaseUser = authResult.user if (App.database_table_users.child(firebaseUser.uid) == null) { var facebookId = "" firebaseUser.providerData .filter { it.providerId == FacebookAuthProvider.PROVIDER_ID } .forEach { facebookId = […]

我想在用kotlin单击Android中的按钮后更改背景

我想单击按钮后更改背景 var bm : Button = messeg bm . setOnClickListener { bm . background = R.color.green } 错误日志: 错误:(35,31)类型不匹配:推断类型是Int,但可绘制! 预期错误:任务':app:compileDebugKotlin'的执行失败。 编译错误。 查看日志了解更多详情

手柄按钮被长按

我希望我的kotlin活动在长时间按下按钮时执行一个动作,而不是在“快速”点击之后进行反应。 什么是最好的办法呢?

浮动动作按钮不被禁用 – Kotlin

我有两个浮动操作按钮。 我想要以编程方式禁用它们,而且它只能用于一个按钮。 但另一个始终在UI中启用。 当我在日志中查看他的状态时,它说禁用,但它正在工作。 这是一个微不足道的代码,但我不明白。 将FloatButtonAction设置为禁用 fab_nfc.isEnabled = false fab_sync.isEnabled = false fab_sync真的被禁用,但另一个没有(在用户界面中) Log.d(TAG, "Fab NFC isEnabled? = ${fab_nfc.isEnabled}") 日志文件 日志文件说这个按钮真的被禁用。 Fab NFC isEnabled? = false 编辑 – 解释代码示例 activity_main.xml中 <android.support.design.widget.FloatingActionButton android:id="@+id/fab_sync" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|end" android:layout_margin="@dimen/fab_margin" app:srcCompat="@drawable/ic_synchronization_arrows" /> <include layout="@layout/content_main" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab_nfc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" app:srcCompat="@drawable/ic_nfc_near_field_communication" /> content_main.xml <FrameLayout android:id="@+id/contentMainFrameLayoutId" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/transparentBackground" […]

Kotlin多点击按钮上的听众

所以对于kotlin来说,我想知道如何将多个点击事件添加到xml中定义的按钮中,就像以前在Java中一样,我们实现了View.onClickListener接口,并在onClick方法中完成其余的工作。 例如: @Override public void onClick(View v) { switch (v.getId()) { case R.id.oneButton: // do your code break; case R.id.twoButton: // do your code break; case R.id.threeButton: // do your code break; default: break; } } 我正在用新的Kotlin制作一个基本的计算器应用程序,但似乎Kotlin没有这样的规定,而是我的代码看起来太长而冗长,因为我将事件附加到所有按钮单独。 有人能告诉我如何在科特林做同样的方式吗? 谢谢