Post

AlertDialog, Snackbar, Toast / String resource

AlertDialog
1
2
3
4
5
6
7
8
fun finishDialog(activity : AppCompatActivity, title : String?, message : String?) {
AlertDialog.Builder(activity).setTitle(title)
.setMessage(message)
.setCancelable(false)
.setPositiveButton("종료", { \_, \_ ->
activity.finish()
}).show()
}

내부에서 ContextThemeWrapper를 사용하기 때문에 baseContext를 넘기면 강제 종료된다.

Snackbar
1
2
3
listView.setOnItemClickListener { parent, v, position, id ->
Snackbar.make(v, "Sometext", Snackbar.LENGTH\_LONG).setAction("Action", null).show()
}
Toast
1
Toast.makeText(this, "송신 완료", Toast.LENGTH\_LONG).show()
문자열 리소스 가져오기
1
resources.getString(R.string.string\_name)
TextView에 스크롤바 붙이기
1
2
<TextView ....
android:scrollbars="vertical"/>
1
2
mTextView = findViewById<View>(R.id.textView) as TextView
mTextView.movementMethod = ScrollingMovementMethod()
This post is licensed under CC BY 4.0 by the author.