语言切换
This commit is contained in:
@@ -9,6 +9,7 @@ import android.view.WindowManager
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.example.defenseapplication.R
|
||||
import com.example.defenseapplication.utils.AppLanguage
|
||||
import com.example.defenseapplication.utils.LanguageUtil
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,7 @@ import com.example.defenseapplication.utils.LanguageUtil
|
||||
*/
|
||||
class LanguageDialog(
|
||||
context: Context,
|
||||
private val onLanguageSelected: (String) -> Unit
|
||||
private val onLanguageSelected: (AppLanguage) -> Unit
|
||||
) : Dialog(context, R.style.BottomDialogStyle) {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -43,22 +44,21 @@ class LanguageDialog(
|
||||
val tvEnglish = findViewById<TextView>(R.id.tvEnglish)
|
||||
val tvCancel = findViewById<TextView>(R.id.tvCancel)
|
||||
|
||||
val currentLang = LanguageUtil.getCurrentLanguage(context)
|
||||
val currentLang = LanguageUtil.currentLanguage
|
||||
|
||||
// 根据当前语言高亮显示
|
||||
if (currentLang == LanguageUtil.LANGUAGE_CHINESE) {
|
||||
if (currentLang == AppLanguage.SIMPLIFIED_CHINESE) {
|
||||
tvChinese.setTextColor(context.getColor(R.color.green))
|
||||
} else {
|
||||
tvEnglish.setTextColor(context.getColor(R.color.green))
|
||||
}
|
||||
|
||||
llChinese.setOnClickListener {
|
||||
onLanguageSelected(LanguageUtil.LANGUAGE_CHINESE)
|
||||
onLanguageSelected(AppLanguage.SIMPLIFIED_CHINESE)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
llEnglish.setOnClickListener {
|
||||
onLanguageSelected(LanguageUtil.LANGUAGE_ENGLISH)
|
||||
onLanguageSelected(AppLanguage.ENGLISH)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user