標籤:des android class blog code http
#Region Project Attributes #ApplicationLabel: ListViewTest#VersionCode: 20140625#VersionName: ‘SupportedOrientations possible values: unspecified, landscape or portrait.#SupportedOrientations: unspecified#CanInstallToExternalStorage: False#End Region#Region Activity Attributes #FullScreen: False#IncludeTitle: True#End RegionSub Process_Globals‘These global variables will be declared once when the application starts.‘These variables can be accessed from all modules.‘ 本工程修改於《basic4android 開發教程翻譯(八)使用ListView 》End SubSub Globals‘These global variables will be redeclared each time the activity is created.‘These variables can only be accessed from this module.Private lvwBrowser As ListView ‘ 聲明組件End SubSub Activity_Create(FirstTime As Boolean)‘Do not forget to load the layout file created with the visual designer. For example:Activity.LoadLayout("1")Dim gd As GradientDrawable ‘ 漸層效果類,GradientDrawable 支援使用漸層色來繪製圖形gd.Initialize("TOP_BOTTOM", Array As Int(Colors.Black , Colors.LightGray))‘第一個參數定義漸層的方向,有下列值供選擇‘"TOP_BOTTOM" "頂部->底部" ‘"TR_BL" (Top-Right To Bottom-Left) (右上->左下) ‘"RIGHT_LEFT" "右->左" ‘"BR_TL" (Bottom-Right To Top-Left) "BR_TL" (左下->右上) ‘"BOTTOM_TOP" "底部->頂部" ‘"BL_TR" (Bottom-Left To Top-Right) "BL_TR" (左下->右上) ‘"LEFT_RIGHT" "左->右" ‘"TL_BR" (Top-Left To Bottom-Right) (左上->到右下)Activity.Background = gd ‘ Activity表單背景使用漸層色效果lvwBrowser.Width =100%xlvwBrowser.ScrollingBackgroundColor = Colors.Transparent ‘ 縱向捲軸背景色=透明lvwBrowser.Initialize ("lvwBrowser")lvwBrowser.SingleLineLayout.Label.TextSize =20 ‘ 字型大小lvwBrowser.SingleLineLayout.Label.TextColor = Colors.Green ‘ 字型顏色 lvwBrowser.SingleLineLayout.Label.Gravity =Gravity.LEFT ‘ 字型顯示位置lvwBrowser.SingleLineLayout.ItemHeight = 60dip ‘ 行高度lvwBrowser.TwoLinesLayout.Label.TextSize =20 ‘ 字型大小lvwBrowser.TwoLinesLayout.Label.TextColor =Colors.Yellow ‘ 字型顏色lvwBrowser.TwoLinesLayout.SecondLabel.TextSize =20 ‘ 字型大小lvwBrowser.TwoLinesLayout.SecondLabel.TextColor =Colors.Red ‘ 字型顏色lvwBrowser.FastScrollEnabled = True ‘ 快速滾動器Dim BitmapIcon As BitmapBitmapIcon.Initialize(File.DirAssets, "1.png")Dim i As Int For i=1 To 20lvwBrowser.AddSingleLine("單行項(AddSingleLine) " & i)lvwBrowser.AddTwoLines ("文本雙行項(AddTwoLines)" & i," —— 第二行Text —— " & i)lvwBrowser.AddTwoLinesAndBitmap("圖形雙行項" & i, " —— 第二行Text —— " & i,BitmapIcon)NextActivity.AddView(lvwBrowser, 0, 0, 100%x, 100%y)End SubSub Activity_ResumeEnd SubSub Activity_Pause (UserClosed As Boolean)End SubSub lvwBrowser_ItemClick (Position As Int, Value As Object)‘ 參數 Position 是清單項目索引‘ 參數 Value 是清單項目文本Activity.Title = "( " & Position & " )" & "-" & ValueEnd Sub