Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use different onKeyDown in fragment of a same activity

I want to use different onKeyDown or onKeyUp in different fragment,but the method is written in the activity.So I want to find a way to write different onKeyDown.

like image 991
Marshal Chen Avatar asked Nov 13 '22 02:11

Marshal Chen


1 Answers

Use FragmentManager's findFragmentById() to check what fragment is currently displayed, and switch for the fragment inside the onKeyDown function

like image 175
Bogdan Alexandru Avatar answered Nov 14 '22 23:11

Bogdan Alexandru