Checkbox

hollywoodjack

Member
Licensed User
Longtime User
I would like to make a preference activity like this...if CheckBox1 is checked, my program must execute the instructions contained in activity2 ... my program is correct? I have this error: "an error has occurred in sub: main_createpreferencescreen (java line:249)...have you declared this activity in your AndroidManifest.xml?" I must declared the activity in my manifest?

This is the code:
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim screen As PreferenceScreen
   Dim manager As PreferenceManager
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
End Sub

Sub Activity_Create(FirstTime As Boolean)
   CreatePreferenceScreen
End Sub

   
Sub CreatePreferenceScreen
   screen.Initialize("screen","")
   Dim cat1 As PreferenceCategory
   cat1.Initialize("Category 1")
   cat1.AddCheckBox("check1", "Checkbox1", "This is Checkbox1", False)
   screen.AddPreferenceCategory(cat1)
   StartActivity(screen.CreateIntent)
End Sub
   
Sub Activity_Resume
   Dim m As Boolean
   m=manager.GetBoolean("check1")
   If m=True Then
   StartActivity(Activity2)
   End If   
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

hollywoodjack

Member
Licensed User
Longtime User
I modified the manifest with this code
B4X:
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)
...no errors now, but the program not work as I want...can you help me?
 
Last edited:
Upvote 0

hollywoodjack

Member
Licensed User
Longtime User
I would to make a sub like
B4X:
sub check1_CheckedChange (checked As Boolean)
if checked=true then
startactivity(Activity2)
end if
end sub
(check1 is a checked box), it's possible?
 
Upvote 0
Top