Hi, I have different screen to work in an android application. I'm using ViewFlipper for this. I decided to used different class for different view 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 the Homescreen class is :-
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 is shows run exception
java.lang.RuntimeException: Unable to start activity ComponentInfo
Can anyone please help me
is getCurrentFocus() is the correct way to get the view?
What i try to implement is
- I need to use different class for defining, listening the controls of each child of view flipper
- In the above example HomeScreen is one of my the child screen of view flipper
- But the line
v.findViewById
is showing error i think that getCurrentFocus() is not the correct way to sent the view
I don't know weather i'm moving in the correct way? When i define and listen all the controls of all children of viewflipper in the Class where i define that viewflpper, that class become very big. That made me to think so..
Thanks...