[android-developers] Re: how to change the font typeface in PreferenceScreen
In my PreferenceActivity I have this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); setContentView(R.layout.preferences); SharedPreferences sharedPreferences = getSharedPreferences("settings", Context.MODE_PRIVATE); sharedPreferences.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Toast.makeText(getApplicationContext(), key, 0).show(); } }); } To test this solution. But I can't see any Toast. On 11 Paź, 02:16, lbendlin wrote: > you might get lucky > viahttp://developer.android.com/reference/android/content/SharedPreferen... > as I believe this is called when the preference is first rendered. > > And then you can poke the individual preference like so > > public void onSharedPreferenceChanged(SharedPreferences > sharedPreferences, String key) { > Preference pref = findPreference(key); > > if (pref instanceof ListPreference) { > ListPreference listPref = (ListPreference) pref; > pref.setSummary(listPref.getEntry()); > > String pT = (String) pref.getTitle(); > ... > > Alternatively, if you only have a few preferences, you should be able to > address them via their key directly. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: how to change the font typeface in PreferenceScreen
In my PreferenceActivity I have this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); setContentView(R.layout.preferences); SharedPreferences sharedPreferences = getSharedPreferences("settings", Context.MODE_PRIVATE); sharedPreferences.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Toast.makeText(getApplicationContext(), key, 0).show(); } }); } To test this solution. But I can't see any Toast. On 11 Paź, 02:16, lbendlin wrote: > you might get lucky > viahttp://developer.android.com/reference/android/content/SharedPreferen... > as I believe this is called when the preference is first rendered. > > And then you can poke the individual preference like so > > public void onSharedPreferenceChanged(SharedPreferences > sharedPreferences, String key) { > Preference pref = findPreference(key); > > if (pref instanceof ListPreference) { > ListPreference listPref = (ListPreference) pref; > pref.setSummary(listPref.getEntry()); > > String pT = (String) pref.getTitle(); > ... > > Alternatively, if you only have a few preferences, you should be able to > address them via their key directly. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: how to change the font typeface in PreferenceScreen
In my PreferenceActivity I have this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); setContentView(R.layout.preferences); SharedPreferences sharedPreferences = getSharedPreferences("settings", Context.MODE_PRIVATE); sharedPreferences.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Toast.makeText(getApplicationContext(), key, 0).show(); } }); } To test this solution. But I can't see any Toast. On 11 Paź, 02:16, lbendlin wrote: > you might get lucky > viahttp://developer.android.com/reference/android/content/SharedPreferen... > as I believe this is called when the preference is first rendered. > > And then you can poke the individual preference like so > > public void onSharedPreferenceChanged(SharedPreferences > sharedPreferences, String key) { > Preference pref = findPreference(key); > > if (pref instanceof ListPreference) { > ListPreference listPref = (ListPreference) pref; > pref.setSummary(listPref.getEntry()); > > String pT = (String) pref.getTitle(); > ... > > Alternatively, if you only have a few preferences, you should be able to > address them via their key directly. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] how to change the font typeface in PreferenceScreen
I have font in file *.ttf in Assets folder. I want to set this font typeface for TextViewews. I have this code, but it doesn't change anything: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); setContentView(R.layout.preferences); PreferenceScreen prefScreen = getPreferenceScreen(); ListAdapter listAdapter = prefScreen.getRootAdapter(); for (int i = 0; i < listAdapter.getCount(); i++) { CheckBoxPreference cbPrefs = (CheckBoxPreference) listAdapter.getItem(i); LinearLayout linearLayout = (LinearLayout) cbPrefs.getView(null, null); RelativeLayout relativeLayout = (RelativeLayout) linearLayout.findViewById(R.id.title_layout); TextView title = (TextView) relativeLayout.findViewById(android.R.id.title); Typeface lucidaGrande = Typeface.createFromAsset(getApplicationContext().getAssets(), "Lucida Grande.ttf"); title.setTypeface(lucidaGrande); } } In another Activity - ListActivity I have overrided SimpleCursorAdapter and in its bindView(View view, Context context, Cursor cursor) method I have used something like that: @Override public void bindView(View view, Context context, Cursor cursor) { super.bindView(view, context, cursor); LinearLayout parentItemLayout = (LinearLayout) view; LinearLayout childItemLayout = (LinearLayout) parentItemLayout.findViewById(R.id.child_layout); LinearLayout infoItemLayout = (LinearLayout) childItemLayout.findViewById(R.id.info_layout); TextView title = (TextView) infoItemLayout.findViewById(R.id.title); Typeface lucidaGrande = Typeface.createFromAsset(getApplicationContext().getAssets(), "Lucida Grande.ttf"); title.setTypeface(lucidaGrande, Typeface.BOLD); } And it works properly. I have my own layout for list item, so I can use findViewById. In Preference Screen I have only CheckBoxPreference also with my own layout. So I should also can use findViewById method to get acces to TextViewes. How can I do similar thing in PreferenceActivity? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] onConfigurationChanged sometimes is not calling in TabActivity
I have noticed that in some cases (for example when user unlock the device and my application is show as first or when I switch several times the tabs and next I change the device orientation) the onConfigurationChanged method of my activities in tabs has not been called. This method of my main TabActivity is always calling when I change the orientation. But why this method is not calling in activity in Tab? I know this because I have done debugging my application and I have also used Toasts in every onConfigurationChanged method. In Manifest file I have: android:configChanges="orientation| keyboardHidden|keyboard" in TabActivity and also in others activities (these in tabs). And of course I have overrided onConfigurationChanged method in each activitiy. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en