Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do you mean callback using interface? if yes here's an example</p> <p>this is callbackmenu.java</p> <pre><code>package com.example.test.callback; public interface CallbackCalendar { public void onClick(); } </code></pre> <p>this is an example how you implement it</p> <pre><code>public class CallbackCell implements CallbackCalendar{ @Override public void onClick() { Log.i("TAG", "IT WORKS!); addChild(2); } } </code></pre> <p>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 </p> <p>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) </p> <p>this is the example of using callback in the calendar cell</p> <pre><code>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); } </code></pre> <p>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</p> <p>I think that's all if you have any question feel free to write in the comment :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload