本文整理汇总了Scala中android.widget.Toast类的典型用法代码示例。如果您正苦于以下问题:Scala Toast类的具体用法?Scala Toast怎么用?Scala Toast使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Toast类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: RalletsWebClient
//设置package包名称以及导入依赖的类
package com.rallets
import android.app.{Activity, AlertDialog, ProgressDialog}
import android.content.DialogInterface
import android.webkit.{WebView, WebViewClient}
import android.widget.Toast
import com.github.shadowsocks.R
class RalletsWebClient(activity: Activity, title: String) extends WebViewClient {
val alertDialog = new AlertDialog.Builder(activity).create()
val progressBar = ProgressDialog.show(activity, title, activity.getString(R.string.loading))
override def onReceivedSslError(view: _root_.android.webkit.WebView, handler: _root_.android.webkit.SslErrorHandler, error: _root_.android.net.http.SslError): Unit = {
import android.content.DialogInterface
val builder = new AlertDialog.Builder(activity)
builder.setMessage(R.string.ssl_error_alert)
builder.setPositiveButton(R.string.continue_browse, new DialogInterface.OnClickListener() {
override def onClick(dialog: DialogInterface, which: Int): Unit = {
handler.proceed
}
})
builder.setNegativeButton(R.string.cancel_browse, new DialogInterface.OnClickListener() {
override def onClick(dialog: DialogInterface, which: Int): Unit = {
handler.cancel
}
})
val dialog = builder.create
dialog.show()
}
override def shouldOverrideUrlLoading(view: WebView, url: String): Boolean = {
view.loadUrl(url)
return false
}
override def onPageFinished(view: WebView, url: String): Unit = {
RUtils.log("Finished loading URL: " + url)
if (progressBar.isShowing()) {
progressBar.dismiss()
}
}
override def onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String): Unit = {
RUtils.log("Error: " + description)
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show()
alertDialog.setTitle("Error")
alertDialog.setMessage(description)
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
def onClick(dialog: DialogInterface, which: Int) {}
})
alertDialog.show()
}
}