#Region Project Attributes
#ApplicationLabel: example
#VersionCode: 1
#VersionName: start
'SupportedOrientations possible values: unspecified, landscape or portrait.
'#SupportedOrientations: unspecified
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: TRUE
#IncludeTitle: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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.
Dim clv1 As control_view
Dim clv3 As control_view
Private Button1 As Button
Private CheckBox1 As CheckBox
Private Spinner1 As Spinner
Dim Location As LocationManager
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Location.Initialize("Location")
Activity.LoadLayout("L1")
End Sub
Sub clv3_ItemClick(Index As Int, Value As Object)
Log(Index & " = " & Value)
End Sub
Sub CreateListItem2(Text As String, Width As Int, Height As Int, phonelist As List) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black
Dim b As Button
b.Initialize("button") 'all buttons click events will be handled with Sub Button_Click
Dim chk As CheckBox
chk.Initialize("chk")
Dim lbl As Label
lbl.Initialize("etiket")
Dim spn As Spinner
Dim spn2 As Spinner
spn.Initialize("spn")
spn2.Initialize("spn2")
spn.AddAll(phonelist)
spn2.AddAll(Array As String("bey","hanım","ablacağım","abiciğim","kardeşim","kuzenim","yeğenim","amcacağım","dayıcığım","halacığım","teyzeciğim", "yengeciğim","dedeciğim","nineciğim","babananeciğim", "anneanneciğim"))
lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
lbl.Text = Text
lbl.TextSize = 16
lbl.TextColor = Colors.White
b.Text = "Click"
'p.AddView( l - T w- h
p.AddView(chk, 5dip, 2dip, 50dip, Height - 4dip) 'view #0
p.AddView(lbl, 55dip, 2dip, 165dip, Height - 4dip) 'view #1
p.AddView(spn, 220dip, 2dip, 170dip, Height - 4dip) 'view #2
p.AddView(spn2, 390dip, 2dip, 150dip, Height - 4dip) 'view #3
Return p
End Sub
Sub Activity_Resume
Location.requestMobileLocation
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
' scrool vieww için hazırlanmış
' https://www.b4x.com/android/forum/threads/class-customlistview-a-flexible-list-based-on-scrollview.19567/#content
'https://www.b4x.com/android/forum/threads/scrollview-examples-summary.8423/#content
ProgressDialogShow("Rehberiniz okunuyor ve listeleniyor...")
DoEvents
'********************* SMS GÖNDERME VE ARAMA *****************************************
'Dim xcall As PhoneCalls
'Dim xsms As PhoneSms
'xsms.Send("+905335135121","2 sistemm çalıstı")
'StartActivity( xcall.Call("02127711379"))
'********************* SMS GÖNDERME VE ARAMA *****************************************
Dim c As Contact
Dim cs As Contacts2
'-------------Liste düzenleme-------------------
clv3.Initialize(Me, "clv3")
Activity.AddView(clv3.AsView, 0, 30%y, 100%x, 70%y)
Dim phonelist As List
phonelist.Initialize
'----------------------------------
Dim l As List
l = cs.GetAll(True,True)
Dim telf As Map
'Msgbox(l.Size, "kişi sayısı")
For i = 0 To l.Size - 1
c = l.Get(i)
telf= c.GetPhones
phonelist.Clear
For z=0 To telf.size-1
phonelist.Add(telf.GetKeyAt(z))
Next
clv3.Add(CreateListItem2( c.DisplayName, clv3.AsView.Width, 40dip,phonelist), 40dip, c.Id)
Log( c.DisplayName)
Next
ProgressDialogHide
' formatting using embedded tokens and the RichTextFormatter
Dim rs As RichString
Dim rsf As RichStringFormatter
rs.Initialize("{R}{T}{Blue}This2{Blue}{T}{R} {U}is{U} one more {Red}{BI}Rich{Red}String{BI}")
rsf.Initialize("{sample}")
rsf.AddToken("{R}", rsf.FORMAT_RELATIVESIZE, 1.5)
rsf.AddToken("{T}", rsf.FORMAT_TYPEFACE, "serif")
rsf.AddToken("{Blue}", rsf.FORMAT_COLOR, Colors.Blue)
rsf.AddToken("{Red}", rsf.FORMAT_COLOR, Colors.Red)
rsf.AddToken("{U}", rsf.FORMAT_UNDERSCORE, Null)
rsf.AddToken("{BI}", rsf.FORMAT_STYLE, rsf.STYLE_BOLD_ITALIC)
rs = rsf.Format(rs)
'Label3.Text = rs
End Sub
Sub spn2_ItemClick (Position As Int, Value As Object)
Msgbox("2 ci","")
End Sub
Sub spn_ItemClick (Position As Int, Value As Object)
Dim index As Int
index = clv3.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv3.GetPanel(index)
Dim spn,spn2 As Spinner
Dim lbl As Label
Dim chk As CheckBox
lbl = pnl.GetView(1)
spn = pnl.GetView(2)
chk = pnl.GetView(0)
spn2 = pnl.GetView(3)
lbl.Text = "telfon!"
Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "spinner value: " & spn.GetItem(Position), "")
End Sub
Sub chk_CheckedChange(Checked As Boolean)
Dim index As Int
index = clv3.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv3.GetPanel(index)
Dim chk As CheckBox
chk = pnl.GetView(0)
'Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
etiket_Click
End Sub
Sub etiket_Click
Dim index As Int
index = clv3.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv3.GetPanel(index)
Dim lbl As Label
Dim chk As CheckBox
lbl = pnl.GetView(1)
chk = pnl.GetView(0)
'Msgbox(lbl.Tag,"")
If chk.Checked=True Then
Dim st,bt As String
Dim rs As RichString
Dim rs2 As RichString
'Dim sf As StringFunctions
'Dim rsf As RichStringFormatter
rs2.Initialize(lbl.Text)
Dim ANS As List
Dim sf As StringFunctions
ANS = sf.Split(lbl.Text, " ")
If lbl.Tag=Null Then lbl.Tag=0
If lbl.Tag=ANS.Size Then lbl.Tag=0
If ANS.Size=1 Then
rs2.Color(Colors.Red,0,lbl.Text.Length)
Else
st=""
For i=0 To (lbl.Tag-1)
st=st&ANS.Get(i)&" "
Next
bt=st&ANS.get(lbl.Tag)
If lbl.Tag+0=0 Then
st=""
bt=ANS.get(lbl.Tag)
End If
rs2.Color(Colors.Red,st.Length,bt.Length)
lbl.Tag=(lbl.Tag*1)+1
End If
lbl.Text =rs2
st=st
Else
' temiz yazar
lbl.Text=lbl.Text
lbl.Tag=Null
End If
'rs.Initialize("{R}{T}{Blue}This2{Blue}{T}{R} {U}is{U} one more {Red}{BI}Rich{Red}String{BI}")
'rsf.Initialize("{sample}")
'rsf.AddToken("{R}", rsf.FORMAT_RELATIVESIZE, 1.5)
'rsf.AddToken("{T}", rsf.FORMAT_TYPEFACE, "serif")
'rsf.AddToken("{Blue}", rsf.FORMAT_COLOR, Colors.Blue)
'rsf.AddToken("{Red}", rsf.FORMAT_COLOR, Colors.Red)
'rsf.AddToken("{U}", rsf.FORMAT_UNDERSCORE, Null)
'rsf.AddToken("{BI}", rsf.FORMAT_STYLE, rsf.STYLE_BOLD_ITALIC)
'rs = rsf.Format(rs)
'lbl.Text =" tamam 2 dır"
End Sub
Sub Button_Click
Dim index As Int
index = clv3.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv3.GetPanel(index)
Dim lbl As Label
Dim chk As CheckBox
lbl = pnl.GetView(1)
chk = pnl.GetView(0)
lbl.Text = "Clicked!"
Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
End Sub
Sub CheckBox1_CheckedChange(Checked As Boolean)
If Checked=True Then
Msgbox("chek edilidi","")
Else
Msgbox("iptal","")
End If
etiket_Click
End Sub
Sub Spinner1_ItemClick (Position As Int, Value As Object)
Msgbox( Spinner1.GetItem(Position),"")
End Sub
Sub Location_LocationChanged (Longitude As Double, Latitude As Double, Altitude As Double, Accuracy As Float, Bearing As Float, Provider As String, Speed As Float, Time As Long)
Log("demnene")
'ToastMessageShow("Long: " & Longitude & " - Lat: " & Latitude,True)
Log("Long: " & Longitude & " - Lat: " & Latitude)
'Msgbox("Long: " & Longitude & " - Lat: " & Latitude & "Accuracy = " & Accuracy & Chr(10) & "Bearing = " & Bearing &Chr(10) & "Provider="& Provider &Chr(10)&"Speed="& Speed&Chr(10) &"Time=" & Time, "")
End Sub
Sub Location_ProviderDisabled (Provider As String)
'ToastMessageShow("Location_ProviderDisable: " & Provider, True)
Log("Location_ProviderDisable: " & Provider)
End Sub
Sub Location_ProviderEnabled (Provider As String)
'ToastMessageShow("Location_ProviderEnabled: " & Provider, True)
Log("Location_ProviderEnabled: " & Provider)
End Sub
Sub Location_StatusChanged (Provider As String, Status As Int)
'ToastMessageShow("Location_StatusChanged: " & Provider & " Status: " & Status, True)
Log("Location_StatusChanged: " & Provider & " Status: " & Status)
End Sub