退出
App
并再次打开它之后,然后language
被更改,如何在不重新启动应用程序的情况下完成我正在使用
RecyclerView
从change_language函数加载数据这是我的change_language函数:
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"));
}
以下是从中提取语言的数组(Instant.java文件中):
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";
答案 0 :(得分: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();
}