注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

沉默蜂B4A安卓编程

国内资料最全的B4A资料库

 
 
 

日志

 
 

[例程]带纵向滚动条的标签  

2014-08-30 22:27:26|  分类: 文件读写 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
通过代码控制安卓标题栏显示与隐藏 - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
例程运行效果图

 
通过代码控制安卓标题栏显示与隐藏 - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
例程运行效果图


通过代码控制安卓标题栏显示与隐藏 - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
布局文件longtext1.bal
 

通过代码控制安卓标题栏显示与隐藏 - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
布局文件longtext.bal

 


Best view (control) for showing a large text file (源码来自44楼)


---------------------------------------------------------------------- 以下是Main模块代码

#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: LongTextWithButton
#VersionCode: 1
#VersionName: 
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

'Activity module
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 lblText As Label
Dim scvText As ScrollView
Dim spnTexts, spnFont, spnFontSize As Spinner
Dim Default, Times, Lucinda As Typeface
Dim obj1 As Reflector
Dim btnTop As Button
Dim txt As String 
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim i As Int
Activity.LoadLayout("LongText")
scvText.Height = Activity.Height - scvText.Top - 10dip
scvText.Width = Activity.Width 
scvText.Panel.LoadLayout("LongText1")
btnTop.Left = (scvText.Width - btnTop.Width) / 2
obj1.Target=lblText
Times=Typeface.LoadFromAssets("times.ttf")
Lucinda=Typeface.LoadFromAssets("LHANDW.ttf")
FillTextFileSpinner
FillFontSpinner
FillFontSizeSpinner
spnTexts.SelectedIndex = 2
LoadText
SetText

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub FillTextFileSpinner
Dim i As Int
Dim tx As String
Dim FileList As List
FileList=File.ListFiles(File.DirAssets)
spnTexts.Clear
For i=0 To FileList.Size-1
tx=FileList.Get(i)
If tx.SubString(tx.Length-3)="txt" Then
spnTexts.Add(tx)
End If
Next
End Sub

Sub FillFontSpinner
spnFont.Add("Default")
spnFont.Add("Times")
spnFont.Add("Lucida")
End Sub

Sub FillFontSizeSpinner
spnFontSize.Add(14)
spnFontSize.Add(16)
spnFontSize.Add(20)
End Sub

Sub LoadText
txt=File.GetText(File.DirAssets,spnTexts.SelectedItem)
End Sub

Sub spnTexts_ItemClick (Position As Int, Value As Object)
LoadText
SetText
End Sub

Sub spnFont_ItemClick (Position As Int, Value As Object)
If Position=0 Then
lblText.Typeface=Typeface.Default
Else If Position=1 Then
lblText.Typeface=Times
Else If Position=2 Then
lblText.Typeface=Lucinda
End If
SetText
End Sub

Sub spnFontSize_ItemClick (Position As Int, Value As Object)
lblText.TextSize=Value
SetText
End Sub

Sub SetText
Dim ht As Float
lblText.Width = -2
lblText.Text=txt
DoEvents
ht=obj1.RunMethod("getHeight") 
DoEvents
btnTop.Top = ht + 20dip 
scvText.Panel.Height=ht + btnTop.Height + 20dip
Log(ht)
If scvText.Panel.Width=scvText.Width OR scvText.Panel.Width=-1 Then
scvText.Panel.Width=scvText.Width-1
Else
scvText.Panel.Width=scvText.Width
End If
scvText.ScrollPosition=0
scvText.Invalidate
End Sub

Sub btnTop_Click
scvText.ScrollPosition = 0
End Sub

 
  评论这张
 
阅读(243)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017