Two different layouts are not working on single activity



i have two xml layouts with one activity i used setContentView() for calling them but when i call the second view it called but not working. here is the code: when i click the fok button the the second layout shows but the buttons on it are not working. please help



protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_reset_pas);
setContentView(R.layout.forpasrest);

fok.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
fok.setBackgroundColor(Color.rgb(220, 215, 255));
setContentView(R.layout.activity_reset_pas);

flag=false;
}

});

fback.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
fback.setBackgroundColor(Color.rgb(220, 215, 255));

Intent intent = new Intent(ResetPasActivity.this,SignInActivity.class);
startActivity(intent);
finish();

}
});

if(flag==false){

ok.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show();

}
});

back.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
back.setBackgroundColor(Color.rgb(220, 215, 255));
Intent intent = new Intent(ResetPasActivity.this,SignInActivity.class);
startActivity(intent);
finish();
}
});
}
}

No comments:

Post a Comment