gpt4 book ai didi

android - 语言不变

转载 作者:行者123 更新时间:2023-11-30 05:01:33 26 4
gpt4 key购买 nike

After I exit my App and open it again, then language is changed, how can I do it without restarting the App

I am using RecyclerView to load the data from change_language function

Here is my change_language function :

public void change_language() {
if (EasyPreference.with(getApplicationContext(), PRE_KEY)
.getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_ASSEMESS)) {

myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_google_classroom, Constant.classroom[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_news_alerts, Constant.news[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_school_rank, Constant.announcement[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.school_diary, Constant.school_diary[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_absent_report, Constant.absent_report[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.examination, Constant.examination[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_events, Constant.events[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_resources, edu_forum[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.edu_forum_finals, Constant.edu_forum[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.sets, Constant.settings[2]));


} else if (EasyPreference.with(getApplicationContext(), PRE_KEY)
.getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_THI)) {

myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_google_classroom, Constant.classroom[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_news_alerts, Constant.news[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_school_rank, Constant.announcement[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.school_diary, Constant.school_diary[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_absent_report, Constant.absent_report[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.examination, Constant.examination[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_events, Constant.events[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_resources, edu_forum[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.edu_forum_finals, Constant.edu_forum[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.sets, Constant.settings[1]));


} else {

myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_google_classroom, "Classroom"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_news_alerts, "Notice"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_school_rank, "Announcement"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.school_diary, "School Diary"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_absent_report, "Absent report"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.examination, "Examination"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_events, "Events"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_resources, "Edu Forum"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.edu_forum_finals, "Edu Bank"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.sets, "Settings"));

}

Here are the Arrays from where the language is fetched (Inside Constant.java file ):

  public static String[] edu_forum = {"Edu Forum", "ฟอรั่มการศึกษา", "শিক্ষা আলোচনা"};
public static String[] news = {"Notice", "ข่าว", "জাননী"};
public static String[] events = {"Events", "เหตุการณ์ที่เกิดขึ้น", "ইভেণ্টসমূহ"};
public static String[] fundraising = {"Fundraising", "การระดมทุน", "দান-বৰঙণি"};
public static String[] volunteer = {"Volunteer", "อาสาสมัคร", "সেচ্ছাকৰ্ম্মী"};
public static String[] media = {"Media", "สื่อ", "প্ৰচাৰ"};
public static String[] photo = {"Photo", "ภาพถ่าย", "ছবি"};
public static String[] video_album = {"Videos", "สื่อ", "প্ৰচাৰ"};
public static String[] resources = {"Edu Bank", "ธนาคารเ", "শিক্ষা বেংক"};
public static String[] directory = {"Directory", "ไดเรกทอรี", "ডাইৰেক্টৰী"};
public static String[] payment = {"Payment", "การชำระเงิน", "পৰিশোধ"};
public static String[] supply = {"Supply", "จัดหา", "সৰবৰাহ"};
public static String[] shool_rank = {"School Rank", "อันดับของโรงเรียน", "বিদ্যালয় স্থান"};
public static String[] lunch_menu = {"Lunch Menu", "เมนูอาหารกลางวัน", "খুৱাৰ তালিকা"};
public static String[] absent_report = {"Absent Report", "ขาด การรายงาน", "অনুপস্হিত প্ৰতিবেদন"};
public static String[] school_bus = {"School Bus", "โรงเรียน รถบัส", "বিদ্যালয় বাছ"};
public static String[] review = {"Review", "ทบทวน", "নিৰীক্ষণ"};
public static String[] library = {"Library System", "ระบบห้องสมุด", "পুথিভৰাঁল"};
public static String[] health = {"Health Profile", "ข้อมูลสุขภาพ", " স্বাস্থ্য প্রোফাইল"};
public static String[] about_us = {"About Us", "เกี่ยวกับเรา", "আমাৰ বিষয়ে"};
public static String[] help = {"Help", "ช่วยด้วย", "সাহায্য"};
public static String[] settings = {"Settings", "การตั้งค่า", "ছেটিংছ"};
public static String[] share = {"Share", "หุ้น", "ভাগ-বতৰা"};
public static String[] classroom = {"Class Room", "ห้องเรียน", "শ্রেণীৰ কোঠা"};
public static String[] google_classroom = {"Google Classroom", "Google ห้องเรียน", "Google শ্ৰেণী"};
public static String[] school_diary = {"School Diary", "โรงเรียน ไดอารี่", "বিদ্যালয় ডায়েৰী"};
public static String[] examination = {"Examination", "การตรวจสอบ", "পৰীক্ষা"};
public static String[] announcement = {"Announcement", "การประกาศ", "ঘোষণা"};
public static String[] birthday = {"Birthday", "วันเกิด", "জন্মদিন"};


public static String COUNTRY_CODE = "91";
public static String PRE_USER_ACTIVE = "0";

最佳答案

添加列表后,只需notifyDataSetChanged如下

 public void change_language() {
if (EasyPreference.with(getApplicationContext(), PRE_KEY)
.getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_ASSEMESS)) {

myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_google_classroom, Constant.classroom[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_news_alerts, Constant.news[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_school_rank, Constant.announcement[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.school_diary, Constant.school_diary[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_absent_report, Constant.absent_report[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.examination, Constant.examination[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_events, Constant.events[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_resources, edu_forum[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.edu_forum_finals, Constant.edu_forum[2]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.sets, Constant.settings[2]));

adapter.notifyDataSetChanged();
} else if (EasyPreference.with(getApplicationContext(), PRE_KEY)
.getString(PRE_USER_LANGUAGE, PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_THI)) {

myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_google_classroom, Constant.classroom[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_news_alerts, Constant.news[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_school_rank, Constant.announcement[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.school_diary, Constant.school_diary[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_absent_report, Constant.absent_report[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.examination, Constant.examination[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_events, Constant.events[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_resources, edu_forum[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.edu_forum_finals, Constant.edu_forum[1]));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.sets, Constant.settings[1]));
adapter.notifyDataSetChanged();

} else {

myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_google_classroom, "Classroom"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_news_alerts, "Notice"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_school_rank, "Announcement"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.school_diary, "School Diary"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_absent_report, "Absent report"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.examination, "Examination"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_events, "Events"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.home_resources, "Edu Forum"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.edu_forum_finals, "Edu Bank"));
myTeacherModelLists.add(new MyTeacherModel(R.drawable.sets, "Settings"));
adapter.notifyDataSetChanged();
}

关于android - 语言不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58166588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com