Sub Process_Globals
Dim Font As String
Dim Size As Int
End Sub
Sub Globals
Dim Color As ColorPickerDialog
Private btncolor As Button
Private BtnSave As Button
Private FontSize As SeekBar
Private FontType As Spinner
Private Label1 As Label
Private Label2 As Label
Private Label3 As Label
Private Label4 As Label
Private Label5 As Label
Private OpenList As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("LSetting")
FontType.AddAll(Array As String("B Nazanin","B Elham","B Farnaz","B Homa","B Kamran","B Mitra"))
Label4.TextSize=18
FontSize.Value = Size
Label1.Typeface=Typeface.LoadFromAssets("B Nazanin.ttf")
Label4.Gravity=Gravity.CENTER
Label2.Typeface=Typeface.LoadFromAssets("B Nazanin.ttf")
Label2.Gravity=Gravity.CENTER
Label3.Typeface=Typeface.LoadFromAssets("B Nazanin.ttf")
Label4.Typeface=Typeface.LoadFromAssets("B Nazanin.ttf")
Label4.Gravity=Gravity.CENTER
Label5.Typeface=Typeface.LoadFromAssets("B Nazanin.ttf")
End Sub
Sub FontType_ItemClick (Position As Int, Value As Object)
If Position = 0 Then
Label4.Typeface=Typeface.LoadFromAssets("B Nazanin.TTF")
End If
If Position = 1 Then
Label4.Typeface=Typeface.LoadFromAssets("B Elham.TTF")
End If
If Position = 2 Then
Label4.Typeface=Typeface.LoadFromAssets("B Farnaz.TTF")
End If
If Position = 3 Then
Label4.Typeface=Typeface.LoadFromAssets("B Homa.TTF")
End If
If Position = 4 Then
Label4.Typeface=Typeface.LoadFromAssets("B Kamran.TTF")
End If
If Position = 5 Then
Label4.Typeface=Typeface.LoadFromAssets("B Mitra.TTF")
End If
End Sub
Sub FontSize_ValueChanged (Value As Int, UserChanged As Boolean)
Label4.TextSize=Value
Label5.Text=Value
End Sub
Sub btncolor_Click
Color.Show("کلکسیون رنگ ها","انتخاب","انصراف","",LoadBitmap(File.DirAssets,"Colors.png"))
btncolor.Typeface=Typeface.LoadFromAssets("B Nazanin.ttf")
code.saveData("setting.txt","FontColor",Color.RGB)
Label4.TextColor=Color.RGB
btncolor.TextColor=Color.RGB
End Sub
Sub BtnSave_Click
Font=FontType.SelectedItem
Size=FontSize.Value
Dim list1 As List
list1.Initialize
list1.Add(Font)
list1.Add(Size)
File.WriteList(File.DirInternal,"Settings.stg",list1)
ToastMessageShow("تنظیمات با موفقیت اعمال شد",False)
StartActivity(Welcome)
Activity.Finish
End Sub
و توی اکتویتی یی که مطالبم هست (مطالب با دیتابیس ساخته شده) این کدهارو گذاشتم:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim s As SQL
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.
Private ScrollView1 As ScrollView
Private lblttl3 As Label
Private lblttl4 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("L1")
If File.Exists(File.DirInternal,"L1.db")=False Then
File.Copy(File.DirAssets,"L1.db",File.DirInternal,"L1.db")
End If
If s.IsInitialized=False Then
s.Initialize(File.DirInternal,"L1.db",False)
End If
lblttl3.Gravity=Gravity.CENTER
lblttl3.TextColor=Colors.White
lblttl4.Gravity=Gravity.CENTER
lblttl4.TextColor=Colors.Red
show
End Sub
Sub show
Dim sh As Int
sh=0
Dim cur As Cursor
cur=s.ExecQuery("Select * from L1")
Dim h As Int
h=5%y
For i=0 To cur.RowCount-1
cur.Position=i
If cur.GetInt("type")=0 Then
Dim lbl As Label
lbl.Initialize("")
lbl.Text=cur.GetString("value")
lbl.Gravity=Gravity.RIGHT
lbl.TextSize=18
lbl.Typeface=Typeface.LoadFromAssets("b nazanin.ttf")
lbl.TextColor=Colors.Black
If File.Exists(File.DirInternal,"Settings.stg")=True Then
Dim list1 As List
list1=File.ReadList(File.DirInternal,"Settings.stg")
Setting.font=list1.Get(0)
Setting.size=list1.Get(1)
Dim a As String
a = code.getData("setting.txt","FontColor")
lbl.TextColor = code.getData("setting.txt","FontColor")
Else
Setting.font="b nazanin.ttf"
Setting.size=25
End If
lbl.Typeface=Typeface.LoadFromAssets(Setting.font &".ttf")
ScrollView1.Panel.AddView(lbl,2%x,h,96%x,0)
Dim su As StringUtils
lbl.Height=su.MeasureMultilineTextHeight(lbl,lbl.Text)
h=h+lbl.Height+2%y
sh=sh+lbl.Height
ScrollView1.Panel.Height=sh
Else
Dim img As ImageView
img.Initialize("")
img.Bitmap=Namayesh(i)
Dim bp As BitmapExtended
bp.initialize("")
ScrollView1.Panel.AddView(img,12%x,h,bp.getwidth(img.Bitmap),bp.getheight(img.Bitmap))
img.Gravity=Gravity.FILL
h=h+bp.getheight(img.Bitmap)+2%y
sh=sh+bp.getheight(img.Bitmap)
ScrollView1.Panel.height=sh
End If
ScrollView1.Panel.Height=ScrollView1.Panel.Height+30%y
Next
End Sub
Sub Namayesh(position As String) As Bitmap
Dim cur As Cursor
cur=s.ExecQuery("Select value from L1")
cur.position=position
Dim bytes() As Byte
bytes=cur.GetBlob("value")
Dim input As InputStream
input.InitializeFromBytesArray(bytes,0,bytes.Length)
Dim b As Bitmap
b.Initialize2(input)
input.Close
Return(b)
End Sub
همه ی تنظیمات مثل رنگ و نوع فونت روی متنم اعمال میشه به جز اندازه !!! اندازه هیچ تغییری نمیکنه ...
سوال
imenz 11
سلام دوستان
من یه تنظیمات ساختم با این کد:
لینک ارسال
به اشتراک گذاری در سایت های دیگر
13 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.