B4A Library AHPreferenceActivity Library

corwin42

Expert
Licensed User
Longtime User

This is already possible. With the (AH)PreferenceManager and the setXXX methods you can set any key/value pair you want.
 

corwin42

Expert
Licensed User
Longtime User

Sorry both of your suggestions/questions are not possible.

For your second question you can create the preference view manually in the designer and use the (AH)PreferencesManager to save and load your settings. Another solution would be to use the StateManager Code Module from Erel
 

mterveen

Member
Licensed User
Longtime User
maybe i wasn't too clear. i like the ease that this library allows in setting up categories and options for various settings. however, it i understand correctly, all the options are stored in one big file accessible only by the program (at least on an unrooted device). i want to be able to use these "methods" to create additional setup/configuration screens particular to a created object, in my case various gauges (which may be added/deleted in the program by the user). currently, now when i want to "configure" a gauge, i have to use a custom list view, generate "headers", then add panels for each type of gauge option that includes a description and field to modify (e.g. text,int, double, boolean, etc) and place them under the appropriate header. since this info is dynamic and is unique for each type of gauge which may be part of many different layouts, it would be nice to be able to use the methods/techniques in this library to save/restore the data from a file specific to the gauge or layout. i do not want to have all the various combinations stored in the main preference library.
 

corwin42

Expert
Licensed User
Longtime User
@mterveen
I don't see any advantage in handling multiple settings files with this library. Why not put all settings for all your gauges in one file?
 

shashkiranr

Active Member
Licensed User
Longtime User
One more question Corwin,

1. I need a category when clicked it should open custom Dialog like date dialog or file dialog

2. It would also be great when any button is clicked i can open an activity.

Is it possible?. If not, is there a workaround which i can use.

Kindly let me know your Inputs and Suggestions.

Regards,
SK
 

corwin42

Expert
Licensed User
Longtime User

It is not possible to open custom dialogs. What you can try is to open a new (invisible) activity which immediately opens a custom dialog. On exiting the dialog you can close the activity then.

You can use the AddIntent() method to open an activity:

B4X:
...
    Dim activityIntent As Intent
    activityIntent.Initialize("your.package.name.action.OPENACTIVITY", "")
    activityIntent.SetComponent(GetPackageName & "/.myactivity")
    catXY.AddIntent("Open Activity", "", activityIntent, "")
...

Sub GetPackageName As String
    Dim r As Reflector
    Return r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
End Sub

And add this to the manifest so the activity listens to the action:

B4X:
AddActivityText(MyActivity, <intent-filter>
              <action android:name="your.package.name.action.OPENACTIVITY" />
              <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>)

you can use any string for the action.
 

gabor

New Member
Licensed User
Longtime User
Hi!

Will the SeekBar be supported in the future? The only thing I miss from this awsome library.

Regards,
Gabor
 

wl

Well-Known Member
Licensed User
Longtime User
Any chance of having an editbox that only accepts numeric values ?

Tx
 

corwin42

Expert
Licensed User
Longtime User
Any chance of having an editbox that only accepts numeric values ?

Tx
Should be possible already with AddEditText2()
 
Reactions: wl

BumForALiving

Member
Licensed User
Longtime User
Can we do an inverse to dependency or can the feature be added? In other words, if a box is checked like "Use default" an edit field is not enabled.

If not and adding it would be considered, my thought is to have a - in the dependency string like:

B4X:
cat1.AddCheckBox("check1", "Checkbox1", "Use default setting", "", True, "")
cat1.AddEditText("edit1", "EditText1", "This is the alternative setting", "", "-check1")

Also, is there a way to launch the settings Activity with a specific settings field already open to edit?
 

corwin42

Expert
Licensed User
Longtime User
The dependancy feature is a feature of the PreferenceActivity Class. Unforunately there is no simple way to use it for inverse dependency.
So I'm sorry but this is not possible.
 

FabioG

Active Member
Licensed User
Longtime User
Hi,

after clicking on this checkbox
B4X:
Tweaks.AddCheckBox("ADJ","Adjust Settings","","",ADJSettings,"")

how do I call a sub?

I need to call a sub to update the config file immediately

Thanks
 

FabioG

Active Member
Licensed User
Longtime User
This is not possible for now.

you think to implement this?


I have another problem, I have the following scenario
B4X:
Dim Device As AHPreferenceCategory
 Device.Initialize("Device Settings")
 Device.AddList("Interface","Interface","",InterfaceVar,"",InterfaceList)
 Device.AddList("Method","Method","",MethodVar,"",MethodList)
 Device.AddCheckBox("Port","Select Port","","",PortVar,"Method")

I need the CheckBox "Port" is active only when I select a particular item from the List "Method"

how can I manage this dependence?
 

corwin42

Expert
Licensed User
Longtime User
Events would be quite complicate to handle with this library.

The dependency system is very limited and what you want to do is not possible with the library. I think it would be easier to implement a custom activity for such "complicated" features. You can still use the PreferencesManager to save your preferences, then.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…