رفتن به مطلب

تعویض اکتیویتی با انیمیشن


amirjun32

ارسال‌های توصیه شده

نمیدونم این اموزشی که می زارم قبلا کسی گذاشته یانه.به هر حال امیدوارم که بدردتون بخوره.از توی سایت مرجع اموزششو دیدم.

خدمت شما:

ابتدا فایل های پیوست رو دانلود کنید،و در مسیر زیر قرار بدید.

Objects\res\anim

این اکتیویتی اولتون هست که کدهای زیر رو توش میزارید.

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main") 'name of my layout file, so it displays something on the screen
End Sub
Sub Button1_Click
    StartActivity(Main2)
    SetAnimation("file3", "file4") 'move the current Activity to the left, and the new activity will come from the right and will scroll to the left
End Sub


Sub SetAnimation(InAnimation As String, OutAnimation As String)
    Dim r As Reflector
    Dim package As String
    Dim In, out As Int
   package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
    In = r.GetStaticField(package & ".R$anim", InAnimation)
    out = r.GetStaticField(package & ".R$anim", OutAnimation)
    r.Target = r.GetActivity
    r.RunMethod4("overridePendingTransition", Array As Object(In, out), Array As String("java.lang.int", "java.lang.int"))
End Sub 

توی اکت دوم هم کد زیر

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main2") 'name of my layout file, so it displays something on the screen
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        Activity.Finish
        SetAnimation("file2", "file1") 'move the current Activity to the right, and the new (or known as the old Activity) will come from the left and will scroll to the right
        Return True
    End If
End Sub

Sub SetAnimation(InAnimation As String, OutAnimation As String)
    Dim r As Reflector
    Dim package As String
    Dim In, out As Int
   package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
    In = r.GetStaticField(package & ".R$anim", InAnimation)
    out = r.GetStaticField(package & ".R$anim", OutAnimation)
    r.Target = r.GetActivity
    r.RunMethod4("overridePendingTransition", Array As Object(In, out), Array As String("java.lang.int", "java.lang.int"))
End Sub

anim.zip

لینک ارسال
به اشتراک گذاری در سایت های دیگر

ممنونم برادر ولی لبتدا سرچ کنید سپس آموزش رو بذارید

لینک ارسال
به اشتراک گذاری در سایت های دیگر

فایلهایی که درون پوشه res گذاشته میشه باید read Only بشه یادتون نره

لینک ارسال
به اشتراک گذاری در سایت های دیگر

بایگانی شده

این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.

  • کاربران آنلاین در این صفحه   0 کاربر

    • هیچ کاربر عضوی،در حال مشاهده این صفحه نیست.
×
×
  • اضافه کردن...