Do you mean callback using interface?
if yes here's an example
this is callbackmenu.java
package com.example.test.callback;
public interface CallbackCalendar {
public void onClick();
}
this is an example how you implement it
public class CallbackCell implements CallbackCalendar{
@Override
public void onClick() {
Log.i("TAG", "IT WORKS!);
addChild(2);
}
}
this is an example that will allow you to access a view from another view
like what I use in my calendar library, I create 3 view classes, calendar View, calendar row, calendar cell
with passing this callback from calendar view to calendar cell we can add view,set value or anything else in the calendar view from the calendar cell (calendar cell is a part of calendar row and calendar row is a part of calendar view) in this example I'm trying to set whenever the user click the cell we will add another view in the calendar view (main view)
this is the example of using callback in the calendar cell
public CalendarCell(Context context,int day,final CallbackCalendar callback)
{
super(context);
final int temp = day;
this.context = context;
this.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
LinearLayout.LayoutParams lpCalendarCell = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
lpCalendarCell.weight = 1;
this.setLayoutParams(lpCalendarCell);
this.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
callback.onClick();
}
});
addContainer(day);
}
so I set the callback in the calendar view and pass it to the calendar row and pass it again to the calendar cell and call the onClick in the calendar cell
I think that's all if you have any question feel free to write in the comment :)