Sliding Menu ျဖင့္ Panels (pages) ေျပာင္းျပျခင္း
Sliding Menu ကို အရင္ project မွာ ေရးျပခဲ့ပါၿပီ။ အခု project မွာေတာ့ menu panel ေပၚက button ေတြကို ႏွိပ္လိုက္ရင္ သက္ဆိုင္ရာ panel (page) ေတြကို ေျပာင္းျပႏိုင္ေအာင္ ဖန္တီးပါမယ္။
===========
Views Panel
===========
x1=-50%x
SetTimerInterval(1)
hidden=true
AddPanel("pnlMain",0,0,100%x,100%y,"")
AddLabel("lbl",0,0,100%x,100%y,"pnlMain")
AddPanel("pnlMenu",x1,0,50%x,100%y,"")
SetColor( "pnlMenu",0,cblue)
AddButton("btn1",22,160,266,119,"pnlMenu")
SetText( "btn1","Page 1")
AddButton("btn2",29,310,258,106,"pnlMenu")
SetText( "btn2","Page 2")
AddButton("btn3",36,450,254,117,"pnlMenu")
SetText( "btn3","Page 3")
AddPanel("p1",0,0,100%x,100%y,"pnlMain")
SetColor("p1",0,cGreen)
AddPanel("p2",0,0,100%x,100%y,"pnlMain")
SetColor("p2",0,cYellow)
AddPanel("p3",0,0,100%x,100%y,"pnlMain")
SetColor("p3",0,cRed)
current="p1"
SetVisible("p2",false)
SetVisible("p3",false)
===========
Events Panel
===========
Sub Activity_Pause(UserClosed)
End Sub
Sub Activity_Resume
End Sub
sub activity_keypress(key)
if key=4 then
if hidden=false then
SetTimerEnabled(true)
else
activityfinish
end if
end if
if key=82 then
SetTimerEnabled(true)
end if
end sub
Sub Timer_Tick
if hidden=true then
x1=x1+10
if x1>=0 then
x1=0
hidden=false
SetTimerEnabled(false )
end if
else
x1=x1-10
if x1<=-50%x then
x1=-50%x
hidden=true
SetTimerEnabled(false)
end if
end if
Setleft("pnlMenu",x1)
Setleft("pnlMain",x1+50%x)
End Sub
Sub Button_Click(Who)
SetTimerEnabled(true)
select Who
case "btn1"
SetVisible(current,false)
SetVisible("p1",true)
current="p1"
case "btn2"
SetVisible(current,false)
SetVisible("p2",true)
current="p2"
case "btn3"
SetVisible(current,false)
SetVisible("p3",true)
current="p3"
end select
End Sub
===========
No comments:
Post a Comment