View Full Version : درخواست راهنمایی در خصوص انتقال به اکتیویتی جدید بعد از اتمام انیمیشن
amirmalakie
پنج شنبه 11 شهریور 1395, 14:34 عصر
سلام
من یه صفحه ساختم که یه اسپلش اسکرین هست که انیمیشن داره
چجوری بعد از پایان انیمیشن برم اکتیویتی جدید
هرکاری کردم نشد
public class MainActivity extends Activity {
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
StartAnimations();
}
private void StartAnimations() {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
anim.reset();
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
l.clearAnimation();
l.startAnimation(anim);
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
anim.reset();
ImageView iv = (ImageView) findViewById(R.id.logo);
iv.clearAnimation();
iv.startAnimation(anim);
}
}
Nevercom
پنج شنبه 11 شهریور 1395, 15:06 عصر
از متد setAnimationListener استفاده کنید.
Listener رو روی شئ anim ست کنید. اینترفیس Animation.AnimationListener متدی تحت عنوان onAnimationEnd داره که در اون متد میتونید به اکتیویتی دیگه برید.
amirmalakie
پنج شنبه 11 شهریور 1395, 15:44 عصر
از متد setAnimationListener استفاده کنید.
Listener رو روی شئ anim ست کنید. اینترفیس Animation.AnimationListener متدی تحت عنوان onAnimationEnd داره که در اون متد میتونید به اکتیویتی دیگه برید.
میشه بیشتر راهنمایی کنید من تازه کار هستم. اگه رو کد خودم یه توضیح بدید متشگکر می شم
amirmalakie
چهارشنبه 17 شهریور 1395, 17:23 عصر
کد رو عوض کردم ولی همچنان crash می کنه
public class MainActivity extends Activity {
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_main);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
StartAnimations();
}
private void StartAnimations() {
final LinearLayout l = (LinearLayout) findViewById(R.id.lin_lay);
final ImageView iv = (ImageView) findViewById(R.id.logo);
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
l.startAnimation(anim);
Animation anim2 = AnimationUtils.loadAnimation(this, R.anim.translate);
iv.startAnimation(anim2);
anim2.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Intent i = new Intent(MainActivity.this, Home.class);
startActivity(i);
l.clearAnimation();
iv.clearAnimation();
//open your second activity
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
}
SHD.NET
چهارشنبه 17 شهریور 1395, 20:03 عصر
سلام. کدهاتون رو توی تگ های code break قراربدید تا بهم ریخته نشه و راحتتر بشه فهمید
این کدها رو از یکی از نرم افزارهام کپی کردم، بعد از پایان انیمیشن صفحه اینستاگرام رو باز می کنه که به جاش میتونی کدهای خودتو قراربدی:
ImageView img4 = (ImageView) findViewById(R.id.imageView4);
final Animation animRotate = AnimationUtils.loadAnimation(MainActivity.this,R.a nim.anim_rotate);
img4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AnimationSet sets = new AnimationSet(false);
sets.addAnimation(animRotate);
v.startAnimation(sets);
sets.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Intent likeIng = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.instagram.com/_u/sh._.dehnavi"));
likeIng.setPackage("com.instagram.android");
try {
startActivity(likeIng);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/sh._.dehnavi")));
}
}
@Override
public void onAnimationRepeat(Animation animation) {}
});
}
});
موفق باشی :قلب:
amirmalakie
پنج شنبه 18 شهریور 1395, 13:22 عصر
package com.example.royal.myapplication;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
public class MainActivity extends Activity {
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_main);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
StartAnimations();
}
private void StartAnimations() {
final LinearLayout l = (LinearLayout) findViewById(R.id.lin_lay);
final ImageView iv = (ImageView) findViewById(R.id.logo);
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
l.startAnimation(anim);
Animation anim2 = AnimationUtils.loadAnimation(this, R.anim.translate);
iv.startAnimation(anim2);
anim2.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// l.clearAnimation();
//iv.clearAnimation();
//open your second activity
// Intent likeIng = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.instagram.com/_u/sh._.dehnavi"));
// likeIng.setPackage("com.instagram.android");
Intent i = new Intent(getApplicationContext(), Home.class);
try {
startActivity(i);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/sh._.dehnavi")));
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
}
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.