ပံုျပင္ (၁၀) ပုဒ္ ပါတဲ့ apk တခု ေရးမယ္
===========================
ဒီ project က ပံုျပင္ ၁၀ ပုဒ္ ေခါင္းစဥ္ေတြကို listView နဲ႔ ေဖာ္ျပထားၿပီး item တခုကို ေရြးလိုက္ရင္ သက္ဆိုင္ရာ ပံုျပင္ကို ဖတ္လို႔ ရေအာင္ ေရးျပထားပါတယ္။
၁။ ပံုျပင္ေတြကို sample0.txt, sample1.txt, ..., sample10.txt ဆိုၿပီး ေရးသား ဖန္တီးထားပါ။
၂။ အဲဒီ ဖိုင္ေတြကို AddFiles နဲ႔ BMP မွာ ထည့္ပါ။
၃။ ေအာက္က code ေတြကို ေရးပါ။
# Views Panel
SetActivityTitle("Story book")
AddPanel("pnlMain",0,0,100%x,100%y,"")
AddListView("lv1",0,0,100%x,100%y,"pnlMain")
Add("lv1","Story 1")
Add("lv1","Story 2")
Add("lv1","Story 3")
Add("lv1","Story 4")
Add("lv1","Story 5")
Add("lv1","Story 6")
Add("lv1","Story 7")
Add("lv1","Story 8")
Add("lv1","Story 9")
Add("lv1","Story 10")
Reading=false
AddPanel("pnl1",0,0,100%x,100%y,"")
SetVisible("pnl1",false)
AddscrollView("scr1",0,0,100%x,100%y,"pnl1")
getPanel("scr1","pnl2")
Setheight("pnl2",200%y)
# If all Text not Visible,
# increase height
# eg, Setheight("pnl2",600%y)
# eg, AddLabel ("lbl1",0,0, 100%x, 600%y, "pnl2")
AddLabel("lbl1",0,0,100%x,200%y,"pnl2")
# ##############
# Events Panel
Sub Activity_Pause(UserClosed)
End Sub
Sub Activity_Resume
End Sub
# ###############
sub Activity_keypress(key)
if key=4 then
if Reading=true then
SetVisible("pnl1",false)
SetVisible("pnlMain",true)
Reading=false
else
activityfinish
end if
end if
end sub
# ######################
Sub ListView_ItemClick(who, pos, value)
select pos
case 0
str=FileReadString(DirAssets,"sample0.txt")
case 1
str=FileReadString(DirAssets,"sample1.txt")
case 2
str=FileReadString(DirAssets,"sample2.txt")
case 3
str=FileReadString(DirAssets,"sample3.txt")
case 4
str=FileReadString(DirAssets,"sample4.txt")
case 5
str=FileReadString(DirAssets,"sample5.txt")
case 6
str=FileReadString(DirAssets,"sample6.txt")
case 7
str=FileReadString(DirAssets,"sample7.txt")
case 8
str=FileReadString(DirAssets,"sample8.txt")
case 9
str=FileReadString(DirAssets,"sample9.txt")
end select
SetText("lbl1",str)
SetVisible("pnl1",true)
SetVisible("pnlMain",false)
Reading=true
End Sub
# ###############
၄။ Text ေတြကို အျပည့္ ဖတ္လို႔ မရရင္ pnl2 နဲ႔ lbl1 ရဲ့ height ေတြကို တိုးေပးပါ။
# If all Text not Visible,
# increase height
# eg, Setheight("pnl2",600%y)
# eg, AddLabel ("lbl1",0,0, 100%x, 600%y, "pnl2")
၅။ ပံုျပင္ မဟုတ္ပဲ အျခား အေၾကာင္းအရာ ေတြကိုလည္း ေရးသားႏိုင္ပါတယ္။
No comments:
Post a Comment