在Kotlin类中添加ScrollBar

时间:2018-08-09 10:56:45

标签: android kotlin scrollbar

我遇到麻烦ScrollBar,将其添加到Kotlin类中时显示错误。导入库也显示错误。我该怎么办?下面是代码:

import android.widget.Toast
import com.github.barteksc.pdfviewer.PDFView
import com.github.barteksc.pdfviewer.ScrollBar
import kotlinx.android.synthetic.main.activity_pdf.view.*


import java.io.File

class PDF_Activity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_pdf)


        val pdfView = findViewById(R.id.pdfView) as PDFView

        val scrollBar = findViewById<ScrollBar>(R.id.scrollBar)
        pdfView.setScrollBar(scrollBar)

        scrollBar.setHorizontal(false)

        val i = this.intent
        val path = i.extras!!.getString("PATH")


        val file = File(path!!)

        if (file.canRead()) {


            pdfView.fromFile(file).defaultPage(1).onLoad { nbPages -> Toast.makeText(this@PDF_Activity, nbPages.toString(), Toast.LENGTH_LONG).show() }.load()

        }

0 个答案:

没有答案