I have two classes, one is called Frame1 and the other is Frame2. Frame2 has a button that is disabled, what I want is to press the Frame1 button so that the button of the other class activates me, since while I do not press the button 1, the button 2 must not be enabled by anything in the world. I would like to know how it is possible to achieve it, because up to now I get an error.
This is my Frame1 layout:
This is the code of Frame1:
public class Frame1 extends AppCompatActivity implements View.OnClickListener {
public Button frame1btn;
public Frame2 f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_frame1);
f = new Frame2();
frame1btn = (Button)findViewById(R.id.botonframe1);
frame1btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
f.frame2btn.setEnabled(true);
}
This is the layout of Frame2:
This is the code for Frame2:
public class Frame2 extends AppCompatActivity implements View.OnClickListener {
public Button frame2btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_frame2);
frame2btn = (Button)findViewById(R.id.botonframe2);
frame2btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Toast.makeText(this, "Lo lograste!", Toast.LENGTH_SHORT).show();
}
I appreciate the help in advance.