Android app : show PreferenceFragment as a dialog?
Date : March 29 2020, 07:55 AM
hope this fix your issue To do an old fashioned, single page settings screen without PreferenceHeaders, do as follows: In your activity that invokes the settings screen (example is in onMenuItemSelected): case R.id.menuSettings:
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(settingsIntent, GC.SETTINGS_ACTIVITY_ID);
break;
package com.mycompany.project1;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
public class SettingsActivity extends PreferenceActivity {
private final static String TAG = "SettingsAcitivity";
public SettingsActivity() {}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyLog.d(TAG, "onCreate");
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new LocationFragment()).commit();
}
public static class LocationFragment extends PreferenceFragment {
private String TAG = "LocationFragment";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyLog.d(TAG, "onCreate");
addPreferencesFromResource(R.xml.settings);
}
}
}
|
How can I display a Dialog from a PreferenceFragment?
Date : March 29 2020, 07:55 AM
this will help Building on Steve's answer, I also need to set up the DialogFragment to import from android.app.DialogFragment (instead of android.support.v4.app.DialogFragment). The show() function in that library asks for an android.app.FragmentManager, which I can provide via a call to getFragmentManager() as I did within the code I posted in the question.
|
File picker dialog in PreferenceFragment
Tag : java , By : user177910
Date : March 29 2020, 07:55 AM
it should still fix some issue I don't think Andorid have a native file chooser, so you'll have to implement one yourself, or find a library. You could then use the android:onClick property in PreferenceFragment.xml: <EditTextPreference
android:key="DB_URI"
android:title="Database file"
android:onClick="startFileChooser"
android:dependency="DB_default">
public void startFileChooser(MenuItem i){
// Start the file chooser here
}
|
Microsoft Builder SDK 3.8.1.0: Location dialog throws exception Method not found "Void Microsoft.Bot.Builder.Dialog
Tag : chash , By : Roel van Dijk
Date : March 29 2020, 07:55 AM
With these it helps This is known issue the team is going to fix soon. It was reported here and here. To unblock yourself you can just re-compile the library using the latest version of BotBuilder, that will make the trick. Update
|
Android changing Dialog content of a PreferenceFragment
Date : March 29 2020, 07:55 AM
should help you out You should implement Preference.OnPreferenceChangeListener for PreferenceFragment class. Then override onPreferenceChange method and if newValue is correct return true otherwise return false. If you return false then preference value will not change. public class SettingsFragment extends PreferenceFragmentCompat implements
Preference.OnPreferenceChangeListener {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
int number = 0;
try{
number = Integer.parseInt(newValue.toString());
}catch(Exception e){
}
if (number > 0 && number < 10){ //It's an example
return true; // Preference will change
}
return false; // newValue rejected and preference not change
}
}
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.settings);
PreferenceScreen prefScreen = getPreferenceScreen();
Preference editTextPrefernce = prefScreen.findPreference(getString(R.string.pref_key));
if (editTextPrefernce != null && editTextPrefernce instanceof EditTextPreference) {
editTextPrefernce.setOnPreferenceChangeListener(this);
}
}
|