I have three Class
mainActivity.java
public class mainactivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.abc);
}
public void firstDialog()
{
//Do something
//call next method
secondDialog()
}
public void secondDialog()
{
//Do something
}
}
Next is another class which is calling the adaptor class secondclass.java
public class secondclass extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xyz);
//calling and set adaptor
adapter=new Myadaptopr(this,result);
recyclerlist.setAdapter(adapter);
}
//Now the Adaptor class
public class Myadaptopr extends RecyclerView.Adapter<Myadaptopr.ViewHolder> {
@Override
public void onBindViewHolder(final MedicineAdaptor.ViewHolder holder, int position) {
//In this function I need to call firstDialog() Method How Do I proceed.
}
}
My Question is:
How do I call the methods of mainactivity.java class file. I have tried solution: but didn't work because mainactivity class don't call and set the adapter. ((mainactivity)context).firstDialog();