Closed ayushnitra closed 4 years ago
I am not sure if I understand your question correctly. I guess you want to assign event handlers to views that are contained by individual tabs.
In your code you should have a class that extends TabSwitcherDecorator
or StatefulTabSwitcherDecorator
and overrides the method onShowTab
. This is the proper place to initialize the views that are contained in a tab, e.g.:
@Override
public void onShowTab(@NonNull final Context context,
@NonNull final TabSwitcher tabSwitcher, @NonNull final View view,
@NonNull final Tab tab, final int index, final int viewType,
@Nullable final State state,
@Nullable final Bundle savedInstanceState) {
Button button = findViewById(R.id.button);
button.setOnClickListener(...)
}
Please refer to the example app, where a similar piece of code can be found in the class Decorator
in MainActivity
.
Sir How can we work click event or any other event on the tab layout 1 or tab layout 2 Please reply.