من میخوام که اسلایدر مهندس آرتا رو با منوی حرفه ای آقای احسان خانی در کنار هم قرار بدم. در واقع در یک صفحه یک منو قرار دادم و یک اسلایدر هم قرار دادم. ولی خوب برنامه از من ایراد میگیره
من کد رو در اینجا قرار میدم به همراه ارور برنامه . کسی تونست راهنمایی کنه ممنون میشم
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Dim tmrAnimation As Timer
Dim currentPanelBeforePaused As Int
Dim tmrSlider As Timer
End Sub
'*******answercenter.ir************
Sub Globals
Dim sd As SlidingData
Dim startX, startY As Float
Dim SlidingDuration As Int
SlidingDuration = 700
Dim offsetX As Int = 33%x '''''وضعیت نشانگر رو مشخص میکنه
Dim imgs(10) As ImageView
Dim cd , cd2 As ColorDrawable
'*********************
'مربوط به منوی پایین
Dim ac1 As AHQuickAction
Dim ac2 As AHQuickAction3D
Dim men As AHPopupMenu
Private Panel1 As Panel
Private ImageView5 As ImageView
Private ImageView1 As ImageView
Private ImageView2 As ImageView
Private ImageView3 As ImageView
Private ImageView4 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'*************************************************
Dim panels(10) As Panel
cd.Initialize(Colors.Blue,10dip)
cd2.Initialize(Colors.Red,10dip)
For i = 0 To 9
panels(i).Initialize("panels")
imgs(i).Initialize("imgs")
Activity.AddView(panels(i),1%x,7%y,98%x,40%y)
panels(i).SetBackgroundImage(LoadBitmapSample(File.DirAssets,(i+1)&".jpg",panels(i).Width,panels(i).Height))
Activity.AddView(imgs(i),offsetX,(panels(i).Top + panels(i).Height) + 5dip,10dip,10dip)
If i = 0 Then
imgs(i).Background = cd2
Else
imgs(i).Background = cd
End If
offsetX = offsetX + 12dip
Next
sd.Initialize
sd.panels = panels
SlidingPanels.Initialize(sd, SlidingDuration)
sd.targetPanel = -1
sd.currentPanel = currentPanelBeforePaused - 1
ChangePanel(True)
tmrSlider.Initialize("tmrSlider",5000)
tmrSlider.Enabled = True
'***************************
'مربوط به منوی پایین
Activity.LoadLayout("1")
ac1.Initialize("AC")
ac2.Initialize("AC", ac2.VERTICAL)
men.Initialize("AC")
For i = 1 To 5
Dim ai As AHActionItem
Dim bd As BitmapDrawable
Dim Filename, Text As String
Select i
Case 1
Filename = "menu_up_arrow.png"
Text = "گالری"
Case 2
Filename = "menu_down_arrow.png"
Text = "ثبت نام"
Case 3
Filename = "menu_info.png"
Text = "دانلود"
Case 4
Filename = "menu_eraser.png"
Text = "خرید"
Case 5
Filename = "menu_search.png"
Text = "اخبار"
End Select
'Initialize a bitmap drawable and the action item
bd.Initialize(LoadBitmap(File.DirAssets, Filename))
ai.Initialize(i, Text, bd)
ai.Selected = True
'Make the Prev and Next items sticky so they will not close the popup
If i = 1 Or i = 2 Then ai.Sticky = True
'Add the item to both Quickactions popups
ac1.addActionItem(ai)
ac2.addActionItem(ai)
men.AddActionItem(ai)
Next
' Make a nice opening animation (True is default)
ac1.AnimateTrack = True
End Sub
'*******answercenter.ir************
'********
'مربوط به منوی پایین
'Event sub when item is selected
Sub AC_Click (Position As Int, ActionItemID As Int)
Dim Action As AHActionItem
Action = ac1.getActionItem(Position)
'ToastMessageShow(Action.Title & " pressed", False)
If Position = 1 Then
StartActivity("")
'*****************************************
'*****************************************
Else If Position = 2 Then
StartActivity("download")
End If
End Sub
Sub ImageView4_Click
End Sub
Sub ImageView3_Click
End Sub
Sub ImageView2_Click
End Sub
Sub ImageView1_Click
End Sub
Sub ImageView5_Click
ac2.show(Sender)
End Sub
'************************************
Sub Activity_Resume
End Sub
Sub tmrSlider_Tick
ChangePanel(True)
Bullet
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ChangePanel(Left As Boolean)
SlidingPanels.ChangePanel(sd, Left)
End Sub
Sub Animation1_AnimationEnd
SlidingPanels.AnimationEnd(sd)
If sd.targetPanel >= 0 Then
tmrAnimation.Enabled = True
Return
End If
End Sub
Sub tmrAnimation_Tick
tmrAnimation.Enabled = False
ContinueJumping
End Sub
Sub JumpToPanel (Target As Int)
sd.targetPanel = Target
For i = 0 To 1
sd.leftAnimations(i).Duration = SlidingDuration / 2
sd.rightAnimations(i).Duration = SlidingDuration / 2
Next
ContinueJumping
End Sub
Sub ContinueJumping
If sd.targetPanel < 0 Or sd.targetPanel = sd.currentPanel Then
sd.targetPanel = -1
Animation1_AnimationEnd
For i = 0 To 1
sd.leftAnimations(i).Duration = SlidingDuration
sd.rightAnimations(i).Duration = SlidingDuration
Next
Return
End If
SlidingPanels.ChangePanel(sd, sd.targetPanel > sd.currentPanel)
End Sub
Sub Panels_Touch (Action As Int, X As Float, Y As Float)
Select Action
Case Activity.ACTION_DOWN
startX = X
startY = Y
Case Activity.ACTION_UP
If Abs(Y - startY) > 20%y Then Return
If X - startX > 30%x Then
ChangePanel(False)
Bullet
Else If startX - X > 30%x Then
ChangePanel(True)
Bullet
End If
End Select
End Sub
Sub Bullet
For i = 0 To 9
If i = sd.currentPanel Then
imgs(i).Background = cd2
Else
imgs(i).Background = cd
End If
Next
End Sub
'www.AnswerCenter.IR
'[email protected]
'Iranian Android Developer
سوال
viki0028 19
درود و سلام
وقتتون بخیر و شادی
من میخوام که اسلایدر مهندس آرتا رو با منوی حرفه ای آقای احسان خانی در کنار هم قرار بدم. در واقع در یک صفحه یک منو قرار دادم و یک اسلایدر هم قرار دادم. ولی خوب برنامه از من ایراد میگیره
من کد رو در اینجا قرار میدم به همراه ارور برنامه . کسی تونست راهنمایی کنه ممنون میشم
#Region Project Attributes #ApplicationLabel: B4A Example #VersionCode: 1 #VersionName: 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: unspecified #CanInstallToExternalStorage: False #End Region #Region Activity Attributes #FullScreen: False #IncludeTitle: True #End Region Sub Process_Globals Dim tmrAnimation As Timer Dim currentPanelBeforePaused As Int Dim tmrSlider As Timer End Sub '*******answercenter.ir************ Sub Globals Dim sd As SlidingData Dim startX, startY As Float Dim SlidingDuration As Int SlidingDuration = 700 Dim offsetX As Int = 33%x '''''وضعیت نشانگر رو مشخص میکنه Dim imgs(10) As ImageView Dim cd , cd2 As ColorDrawable '********************* 'مربوط به منوی پایین Dim ac1 As AHQuickAction Dim ac2 As AHQuickAction3D Dim men As AHPopupMenu Private Panel1 As Panel Private ImageView5 As ImageView Private ImageView1 As ImageView Private ImageView2 As ImageView Private ImageView3 As ImageView Private ImageView4 As ImageView End Sub Sub Activity_Create(FirstTime As Boolean) '************************************************* Dim panels(10) As Panel cd.Initialize(Colors.Blue,10dip) cd2.Initialize(Colors.Red,10dip) For i = 0 To 9 panels(i).Initialize("panels") imgs(i).Initialize("imgs") Activity.AddView(panels(i),1%x,7%y,98%x,40%y) panels(i).SetBackgroundImage(LoadBitmapSample(File.DirAssets,(i+1)&".jpg",panels(i).Width,panels(i).Height)) Activity.AddView(imgs(i),offsetX,(panels(i).Top + panels(i).Height) + 5dip,10dip,10dip) If i = 0 Then imgs(i).Background = cd2 Else imgs(i).Background = cd End If offsetX = offsetX + 12dip Next sd.Initialize sd.panels = panels SlidingPanels.Initialize(sd, SlidingDuration) sd.targetPanel = -1 sd.currentPanel = currentPanelBeforePaused - 1 ChangePanel(True) tmrSlider.Initialize("tmrSlider",5000) tmrSlider.Enabled = True '*************************** 'مربوط به منوی پایین Activity.LoadLayout("1") ac1.Initialize("AC") ac2.Initialize("AC", ac2.VERTICAL) men.Initialize("AC") For i = 1 To 5 Dim ai As AHActionItem Dim bd As BitmapDrawable Dim Filename, Text As String Select i Case 1 Filename = "menu_up_arrow.png" Text = "گالری" Case 2 Filename = "menu_down_arrow.png" Text = "ثبت نام" Case 3 Filename = "menu_info.png" Text = "دانلود" Case 4 Filename = "menu_eraser.png" Text = "خرید" Case 5 Filename = "menu_search.png" Text = "اخبار" End Select 'Initialize a bitmap drawable and the action item bd.Initialize(LoadBitmap(File.DirAssets, Filename)) ai.Initialize(i, Text, bd) ai.Selected = True 'Make the Prev and Next items sticky so they will not close the popup If i = 1 Or i = 2 Then ai.Sticky = True 'Add the item to both Quickactions popups ac1.addActionItem(ai) ac2.addActionItem(ai) men.AddActionItem(ai) Next ' Make a nice opening animation (True is default) ac1.AnimateTrack = True End Sub '*******answercenter.ir************ '******** 'مربوط به منوی پایین 'Event sub when item is selected Sub AC_Click (Position As Int, ActionItemID As Int) Dim Action As AHActionItem Action = ac1.getActionItem(Position) 'ToastMessageShow(Action.Title & " pressed", False) If Position = 1 Then StartActivity("") '***************************************** '***************************************** Else If Position = 2 Then StartActivity("download") End If End Sub Sub ImageView4_Click End Sub Sub ImageView3_Click End Sub Sub ImageView2_Click End Sub Sub ImageView1_Click End Sub Sub ImageView5_Click ac2.show(Sender) End Sub '************************************ Sub Activity_Resume End Sub Sub tmrSlider_Tick ChangePanel(True) Bullet End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub ChangePanel(Left As Boolean) SlidingPanels.ChangePanel(sd, Left) End Sub Sub Animation1_AnimationEnd SlidingPanels.AnimationEnd(sd) If sd.targetPanel >= 0 Then tmrAnimation.Enabled = True Return End If End Sub Sub tmrAnimation_Tick tmrAnimation.Enabled = False ContinueJumping End Sub Sub JumpToPanel (Target As Int) sd.targetPanel = Target For i = 0 To 1 sd.leftAnimations(i).Duration = SlidingDuration / 2 sd.rightAnimations(i).Duration = SlidingDuration / 2 Next ContinueJumping End Sub Sub ContinueJumping If sd.targetPanel < 0 Or sd.targetPanel = sd.currentPanel Then sd.targetPanel = -1 Animation1_AnimationEnd For i = 0 To 1 sd.leftAnimations(i).Duration = SlidingDuration sd.rightAnimations(i).Duration = SlidingDuration Next Return End If SlidingPanels.ChangePanel(sd, sd.targetPanel > sd.currentPanel) End Sub Sub Panels_Touch (Action As Int, X As Float, Y As Float) Select Action Case Activity.ACTION_DOWN startX = X startY = Y Case Activity.ACTION_UP If Abs(Y - startY) > 20%y Then Return If X - startX > 30%x Then ChangePanel(False) Bullet Else If startX - X > 30%x Then ChangePanel(True) Bullet End If End Select End Sub Sub Bullet For i = 0 To 9 If i = sd.currentPanel Then imgs(i).Background = cd2 Else imgs(i).Background = cd End If Next End Sub 'www.AnswerCenter.IR '[email protected] 'Iranian Android Developer
لینک ارسال
به اشتراک گذاری در سایت های دیگر
6 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.