Android: Can I use another class for another child viewflipper

I have another screen to work in an Android application. For this I use ViewFlipper. I decided to use a different class for different kinds of children

public main extends Activity{
{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sign_in);
    ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);

HomeScreen s = new HomeScreen(getApplicationContext(), getCurrentFocus(), viewFlipper);
  }
} 

and this Homescreen class: -

public class HomeScreen {
private Button signIn;
private Button createAccount;
private View v;
private Context context;
private ViewFlipper viewflipper;

public HomeScreen(Context context,View v,ViewFlipper viewflipper ) {
 this.v=v;
 this.context = context;
 this.viewflipper = viewflipper;


 signIn = (Button) v.findViewById(R.id.button_sign_in_homeScreen);
 createAccount = (Button)v.findViewById(R.id.button_createAccount_homeScreen);
 signIn.setOnClickListener(new View.OnClickListener() {
 public void onClick(View v) {
   viewflipper.setDisplayedChild(1);
  }
 });   
}

but shows java.lang.RuntimeException launch exception: Unable to start ComponentInfo activity Someone please help me
getCurrentFocus () - the correct way to get the view?


I'm trying to implement

  • I need to use a different class to define listening on the controls of each flipper child
  • In the above example, HomeScreen is one of my child flipper view screens.
  • v.findViewById , , getCurrentFocus()

, ? viewflipper , viewflpper, . .

...

+3
1

U Intent :

1: res ur.

2: slideleft.xml

3:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromXDelta="100%p" android:toXDelta="0"
        android:duration="400" />
</set>

4: slideright.xml

step5: ,

<translate android:fromXDelta="-100%p" android:toXDelta="0"
            android:duration="400" />

6:

 target.startAnimation(AnimationUtils.loadAnimation(HomeScreen.this, R.anim.slide_left));

perfroming fadein operation, fadein.xml

<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="0.0" android:toAlpha="1.0"
       android:duration="300" />

<?xml version="1.0" encoding="UTF-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="1.0" android:toAlpha="0.0"
       android:duration="300" />
+4

Source: https://habr.com/ru/post/1770854/


All Articles