【问题标题】:How do you hide TextViews in Kotlin?你如何在 Kotlin 中隐藏 TextViews?
【发布时间】:2021-05-25 23:54:34
【问题描述】:

我前段时间阅读了this 的文章,但如果有人能告诉我如何在 Kotlin 中隐藏 TextViews,我将不胜感激?

谢谢。

编辑:

fun damagePopup( playerHitMonster:View , monsterHitPlayer:View ) {
    val playerDamageText = NumberFormat.getNumberInstance().format(playerDam)
    binding.playerHitMonster.text = getString(R.string.playerHitDam, playerDamageText)
    playerHitMonster.visibility = View.VISIBLE

    val monsterDamageText = NumberFormat.getNumberInstance().format(monsterDam)
    binding.monsterHitPlayer.text = getString(R.string.monsterHitDam, monsterDamageText)
    monsterHitPlayer.visibility = View.VISIBLE
    }

【问题讨论】:

  • 不是我,但可能是因为这是你可以在课程文档中找到的微不足道的东西。
  • monsterHitPlayerplayerHitMonster 绑定到别处,因为您以两种不同的方式访问它们。 binding.monsterHitPlayer.textmonsterHitPlayer.visibility 试试 binding.monsterHitPlayer.visibility = View.VISIBLE

标签: android kotlin textview


【解决方案1】:
textView.visibility = View.VISIBLE // default can see it
textView.visibility = View.INVISIBLE //keeps size just cant see it. 
textView.visibility = View.GONE // size goes to 0 0 and cant see it.

【讨论】:

  • 嗯...visibility 是一个未解决的参考。是否有我需要导入的库/包?
  • 我为视图fun showText (myView: View)添加了参数,但是当我调用该函数时,它说我需要添加参数。怎么回事?
  • 张贴你写的东西
猜你喜欢
  • 1970-01-01
  • 2011-11-24
  • 2014-02-10
  • 1970-01-01
  • 2019-01-27
  • 1970-01-01
  • 1970-01-01
  • 2011-07-15
  • 1970-01-01
相关资源
最近更新 更多