比较布尔值Kotlin Android Studio

时间:2018-09-05 00:15:02

标签: java android kotlin

我如何在android中的textview中生成一个布尔表,因为在添加Kotlin时会给我一个错误?

它没有直接比较布尔值,因为textview不能直接让我用它来实现生成布尔值表的目的

package com.example.user.herramientaslogica
    import android.support.v7.app.AppCompatActivity
    import android.os.Bundle
    import android.widget.Button
    import android.widget.TextView
    import kotlinx.android.synthetic.main.activity_main.*
    import org.w3c.dom.Text
    import android.text.method.ScrollingMovementMethod

    class MainActivity : AppCompatActivity() {

        private val VALUES = booleanArrayOf(true, false)
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)

            val textview:TextView = findViewById(R.id.textview) as TextView

            for (a in VALUES)

            {
                for (b in VALUES)
                {
                    for (c in VALUES)
                        for (d in VALUES)
                        {
                            for (e in VALUES)
                            {
                                for (f in VALUES)
                                {
                                    textview.setText (a + b + c + d + d + e + f )
                                    )
         textview.setMovementMethod(ScrollingMovementMethod())
        }

                            }
                        }
                }
            }
        }
    }
    fun or(x:Boolean, y:Boolean):Boolean {
        return x || y
    }
    fun and(x:Boolean, y:Boolean):Boolean {
        return x && y
    }
    fun xor(x:Boolean, y:Boolean):Boolean {
        return x xor y
    }
    fun conditional(x:Boolean, y:Boolean):Boolean {
        return !(x && y)
    }
    fun bicontional(x:Boolean, y:Boolean):Boolean {
        return x == y
    }
    fun disequal(x:Boolean, y:Boolean):Boolean {
        return x != y
    }

0 个答案:

没有答案