I have 2 activity, called screen1 , screen2 . I use them as fragments (but these are not fragments, but simply an activity), in which there is an ImageButton . screen1 , screen2 I throw in the viewFlipper , which is in activity_main to make Sliding. I did it all, Sliding works, but ... Buttons do not react at all, because there is no handler. I want to make the handlers of these buttons in one main class MainActivity . The question is, how do I get from screen1, screen2 ImageButton and put them handlers in the main class?
So added screen1 and screen2 to the main activity_main , to the ViewFlipper block
flipper = (ViewFlipper) findViewById(R.id.viewFlipper); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); int layouts[] = new int[] { R.layout.screen1, R.layout.screen2 }; for (int layout : layouts){ flipper.addView(inflater.inflate(layout, null)); } 