2016-07-12 2 views
1

я применил переход между слайдами, чтобы перейти к деятельности B через операцию A
активности А -> Активность B
Когда я вернуться к деятельности A (нажмите Назад Button)
активности B -> Мероприятие A
, а затем снова к мероприятию B
Деятельность A -> Деятельность B
Приложение не отвечает. Какая может быть причина и решение? Вот код: -
активность A: -App не отвечает из-за переход

package com.tester; 

import android.annotation.SuppressLint; 
import android.app.ActivityOptions; 
import android.content.Intent; 
import android.graphics.Typeface; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.transition.Scene; 
import android.transition.Slide; 
import android.transition.TransitionManager; 
import android.view.Gravity; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.ViewGroup; 
import android.widget.ImageView; 
import android.widget.TextView; 

public class Anima extends AppCompatActivity { 
    ViewGroup root_scene; 
    Bundle bundle; 
    @SuppressLint("NewApi") 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.anima); 
     root_scene = (ViewGroup) findViewById(R.id.root_scene); 
     ImageView iv = (ImageView) findViewById(R.id.info_image); 
     /*final Slide slide = new Slide(Gravity.TOP); 
     slide.addTarget(R.id.test_image); 
     getWindow().setEnterTransition(slide); 
     */ 
     bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle(); 
     TextView tv = (TextView) findViewById(R.id.head); 
     Typeface type = Typeface.createFromAsset(getAssets(), "roboto.ttf"); 
     tv.setTypeface(type); 
     tv.setText("Armed robbers used Pokémon Go to target victims in Missouri"); 
     iv.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View arg0) { 
       // TODO Auto-generated method stub 
       Intent intent = new Intent(Anima.this,Second.class); 
       startActivity(intent,bundle); 
      } 
     }); 

    } 
} 

активность B: -

import android.annotation.SuppressLint; 
import android.app.ActivityOptions; 
import android.content.Intent; 
import android.graphics.Typeface; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.transition.Slide; 
import android.view.Gravity; 
import android.widget.TextView; 

public class Second extends AppCompatActivity{ 
    Bundle bundle; 
    @SuppressLint("NewApi") 
    @Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.another_scene); 
     bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle(); 
    TextView tv2 = (TextView) findViewById(R.id.details); 
    Typeface type = Typeface.createFromAsset(getAssets(), "robot_light.ttf"); 
    tv2.setTypeface(type); 
    tv2.setText("As popular as Pokémon Go has become, that it sends players out into the real world to find Pokémon is creating new, unexpected problems. The O'Fallon, Missouri Police Department reported on Facebook today that armed robbers have used the app to lure victims in and rob them at gunpoint.\nThe police received reports about the robberies and were able to apprehend four suspects in the area. Apparently, the thieves used the app to set up a beacon at a Pokéstop within the game. Using this method, Sergeant Bill Stringer of the OPD told Motherboard that the culprits were able to rob 11 players, all between the ages of 16 and 18, in the St. Louis and St. Charles counties of Missouri."); 
    Slide slide = new Slide(Gravity.BOTTOM); 
    slide.addTarget(tv2); 
    getWindow().setEnterTransition(slide); 
} 

} 
+2

Просьба поделиться сообщением – sJy

+0

@sJy Приложение не работает. это просто повесить. – user6556461

+0

@sJy См. Правки – user6556461

ответ

1

Перемещайте расслоение инициализацию в деятельности Anima внутри метода OnClick(). Попробуйте

iv.setOnClickListener(new OnClickListener() { 
    @Override 
    public void onClick(View arg0) { 
     // TODO Auto-generated method stub 
     bundle = ActivityOptions.makeSceneTransitionAnimation(Anima.this).toBundle(); 
     Intent intent = new Intent(Anima.this,Second.class); 
     startActivity(intent,bundle); 
    } 
}); 
+0

Метод makeSceneTransitionAnimation (Activity, Pair ...) в типе ActivityOptions не применим для аргументов (новый View.OnClickListener() {}) – user6556461

+0

@ user6556461 Проверить обновленный ответ – sJy

+0

Спасибо, чувак. работая как шарм, может сказать мне ошибку – user6556461

Смежные вопросы