android-fragments

How to fix MainActivity cannot be cast to android.app.TimePickerDialog$OnTimeSetListener in a fragment?

孤街醉人 提交于 2020-07-23 06:53:32
问题 i'm doing my school project in android since days ago, and I got a problem today. I did a menu with fragments and I need to put a TimePickerDialog inside a fragment and for me it's impossible, everytime when I press the button lo launch the Dialog the app crashes. I try to put implements in the class of the TimePickerFragment but it doens't work, I need to bring the things in my main fragment, not in the Dialog. Here is my main fragment, called "DespertarFragment": @Override public View

How to fix MainActivity cannot be cast to android.app.TimePickerDialog$OnTimeSetListener in a fragment?

我与影子孤独终老i 提交于 2020-07-23 06:53:27
问题 i'm doing my school project in android since days ago, and I got a problem today. I did a menu with fragments and I need to put a TimePickerDialog inside a fragment and for me it's impossible, everytime when I press the button lo launch the Dialog the app crashes. I try to put implements in the class of the TimePickerFragment but it doens't work, I need to bring the things in my main fragment, not in the Dialog. Here is my main fragment, called "DespertarFragment": @Override public View

ViewPager2 not able to dynamically add remove fragment

怎甘沉沦 提交于 2020-07-19 10:58:26
问题 Removing/Adding fragments at index results in unexpected behaviour in Viewpager2. This was not possible with ViewPager but expected to work with Viewpager2 . It causes duplicate fragments and out of sync TabLayout . Here is a demo project which reproduces this issue. There is a toggle button which removes a fragment and reattaches it at a particular index. In this case attached fragment should be green but it's blue and there are 2 blue fragments somehow. here is how my adapter looks class

animateLayoutChanges=“true” in BottomSheetView showing unexpected behaviour

ε祈祈猫儿з 提交于 2020-07-16 16:32:17
问题 I have a BottomSheetView which has animateLayoutChanges="true" . Initially it shows up fine. But if change the visibility of a view (inside BottomSheetView ) from GONE to VISIBLE , the app messes up calculations and my BottomSheetView moves to the top of the screen. i have tried setting layout_gravity=bottom at the root of the BottomSheetView layout. But no success. Here I have the image of my BottomSheetView before changing the visibility of any view. (Click image for full size) After I

How to solve Handler() deprecated?

三世轮回 提交于 2020-07-16 07:07:06
问题 Could anyone know, how to fix deprecated waring or any alternate solution for this. Handler().postDelayed({ context?.let { //code } }, 3000) 回答1: If you want to avoid the null check thing in Kotlin ( ? or !! ) you can use Looper.getMainLooper() if your Handler is working with some UI related thing, like this: Handler(Looper.getMainLooper()).postDelayed({ Toast.makeText(this@MainActivity, "LOOPER", Toast.LENGTH_SHORT).show() }, 3000) 回答2: Consider using coroutines scope.launch { delay(3000L) /

How to solve Handler() deprecated?

流过昼夜 提交于 2020-07-16 07:06:04
问题 Could anyone know, how to fix deprecated waring or any alternate solution for this. Handler().postDelayed({ context?.let { //code } }, 3000) 回答1: If you want to avoid the null check thing in Kotlin ( ? or !! ) you can use Looper.getMainLooper() if your Handler is working with some UI related thing, like this: Handler(Looper.getMainLooper()).postDelayed({ Toast.makeText(this@MainActivity, "LOOPER", Toast.LENGTH_SHORT).show() }, 3000) 回答2: Consider using coroutines scope.launch { delay(3000L) /

Where to place sign in credentials check - android Dialog

亡梦爱人 提交于 2020-07-10 09:27:13
问题 I am trying to create a login credential screen when user clicks on a setting button. And if login credentials looks right then it should to settings screen. This is the official tutorial i am following. I am managed to create a dialog and it showing the window once the button is clicked. I also passing back the dialog to the Dialog host and here is the code snippet. // Dialog Fragment public class SignInDialogFragment extends AppCompatDialogFragment { // Use this instance of the interface to

Where to place sign in credentials check - android Dialog

主宰稳场 提交于 2020-07-10 09:27:03
问题 I am trying to create a login credential screen when user clicks on a setting button. And if login credentials looks right then it should to settings screen. This is the official tutorial i am following. I am managed to create a dialog and it showing the window once the button is clicked. I also passing back the dialog to the Dialog host and here is the code snippet. // Dialog Fragment public class SignInDialogFragment extends AppCompatDialogFragment { // Use this instance of the interface to

View pdfs stored in assets folder from listview click in fragment

半世苍凉 提交于 2020-07-10 08:13:48
问题 I have created a ListView in which I would like each item to open a certain .pdf file located in assets/PDFS folder located within my Android App. The following code does not throw any errors, but does not open the file either. Can someone share an idea for the solution? Note that I am using Fragment public class FreshFragment extends Fragment implements OnItemClickListener { ListView lv; String[] titles; public FreshFragment() { } @Override public View onCreateView(LayoutInflater inflater,

FCM Data message is not navigating to desired fragment when app is in background

一笑奈何 提交于 2020-07-10 03:18:08
问题 I have an app with a somewhat complex flow. There is a launcher activity (SplashActivity), then a MainActivity, which has five fragments, then in the fifth fragment, there is the DesiredActivity which has three fragments, one of them being the DesiredFragment. When the app is in foreground and we click on the push notification (data message type), the DesiredFragment opens, no issues there, but when the app is in background, the MainActivity opens, instead of the DesiredFragment, on click of