0
내 활동의 onCreate 중 하나에서 다음을 사용하여 목록보기를 가져옵니다. 적용되는 xml 레이아웃은 xml 파일 "country_row"에서 가져온 것입니다. 이제 공유 환경 설정을 사용하여 내 listview의 일부 레이아웃 (예 : 글꼴 색상, 보존해야하는 배경색)을 변경하고 싶습니다. 내가 아는 한 공유 환경 설정을 사용하여이 작업을 수행 할 수 있습니다. 그러나 XML 파일에서 정의하는 방법을 알고 있다고 가정하면이 섹션에서 같은 "country_row"XML 파일을 사용하여 변경된 글꼴 색상이나 배경색을 적용하는 방법을 적용 할 수 있습니다. 아니면 새 XML 파일을 완전히 정의해야합니까? 내가 혼란스러워하는 길은 무엇입니까?Android 환경 설정 이동 방법
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
int sort = prefs.getInt("sort_pref", -1); // -1 will be the result if no preference was set before
if(sort == 1)
sortOrder = "year";//sort on year
else if (sort == 2)
sortOrder = "country";//sort on country
ContentResolver contentResolver = getContentResolver();
Cursor c = contentResolver.query(CONTENT_URI, null, null, null, sortOrder);
String[] from = new String[] { "year", "country" };
int[] to = new int[] { R.id.year, R.id.country };
SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.country_row, c, from, to);
setListAdapter(sca);
}