How to open Visual Studio Code’s ‘settings.json’ file?

To open the User settings: Open the command palette (either with F1 or Ctrl+Shift+P) Type “open settings” You are presented with a few optionsĀ¹, choose Open User Settings (JSON) This image was taken in the VS Code online editor Which, from the manual and depending on platform, is one of: Windows %APPDATA%\Code\User\settings.jsonĀ² macOS $HOME/Library/Application\ Support/Code/User/settings.json … Read more

Dynamic ListPreference in android

Every XML element in Android can be created programmatically as the element name is also a Java class. Hence you can create a ListPreference in code: CharSequence[] entries = { “One”, “Two”, “Three” }; CharSequence[] entryValues = { “1”, “2”, “3” }; ListPreference lp = new ListPreference(this); lp.setEntries(entries); lp.setEntryValues(entryValues); You could alternatively create it in … Read more

creating a DialogPreference from XML

Here is an example of how to use the dialog preference (subclassing as you mentioned). package dk.myapp.views; import android.content.Context; import android.preference.DialogPreference; import android.util.AttributeSet; /** * The OptionDialogPreference will display a dialog, and will persist the * <code>true</code> when pressing the positive button and <code>false</code> * otherwise. It will persist to the android:key specified in xml-preference. … Read more

Android: How to maximize PreferenceFragment width (or get rid of margin)?

Finally, I found the solution to this. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = super.onCreateView(inflater, container, savedInstanceState); if(v != null) { ListView lv = (ListView) v.findViewById(android.R.id.list); lv.setPadding(10, 10, 10, 10); } return v; } You can set padding by using: setPadding();

Android: How to remove margin/padding in Preference Screen

Updating this for androidx. After a lot of experimentation, I resolved this issue by adding this to each preference that had the excess indentation: app:iconSpaceReserved=”false” Of course, you’ll also need to add this to the PreferenceScreen declaration itself at the top of your xml: xmlns:app=”http://schemas.android.com/apk/res-auto” Follow Up For Custom Preferences I noticed that in the … Read more