fragment

Open Navigation Drawer from Button Click within Fragment (Kotlin)

允我心安 提交于 2020-08-02 04:56:30
问题 I have created a custom button in a Fragment and I am trying to open the Navigation Drawer in the Activity when it is clicked. The Navigation Drawer still opens ok when you swipe across, but the app just crashes when I click the button. I guess this is because I am trying to access from the Fragment, but I am at a loss.. Fragment override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment val binding

ViewPager2 with Tablayout inside a fragment shows no swipe effect in kotlin

99封情书 提交于 2020-07-22 05:13:47
问题 In my MainActivity I have a viewpager2 with Tablayout with 5 tabs. The swipe there is working fine. But in one of the 5 tabs I again have a viewpager2 with a tablayout of 3 tabs. In the inner viewpager2 (which is inside a fragment) the swipe isnt working at all and I don't understand why. The outer viewpager2 is inside a activity while the inner viewpager2 is in the fragment Viewpager2 inside fragment , swipe not working : class FreelancerMyProjectsFragment : Fragment() { lateinit var binding

how to set left and right margin in ButtomSheetDialogFragment Android?

╄→гoц情女王★ 提交于 2020-07-09 04:56:22
问题 I tried to set Margin in ButtonSheetDialogFragment layout but its not working. I have tried to set margin from layout and programatically but its has same result This is my XML file layout_bts_item.xml <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:background="#00000000"> <LinearLayout android:layout_width="match_parent"

How to access local variable by storing it to class variable(global) in java android

a 夏天 提交于 2020-06-17 15:46:47
问题 Fragment A The problem here is whenever I call passitem() , passqty() , passamt() , passtot() i get the value which is declared at the time of intialization.i.e, int totalp = 0; String itemp = "", qtyp = "", amtp = "" .I want the variable itemp=item; , qtyp=qty; , amtp=amt; , totalp=total; i.e,local variable data.Please help me out I'm extremly thankful to YOU all. Also P.S:-when I try to get data itemp , qtyp .etc in onActivityCreated i'm getting it perfectly. public class Fragment_nonveg

Initializing ViewModel in fragment Android java

回眸只為那壹抹淺笑 提交于 2020-06-17 09:17:16
问题 I am trying to initialize my viewmodel object in the FirstFragment.java file of BasicActivity . All theses four codes are failed. The documentation could not help me much. mViewModel = new ViewModelProvider(this).get(MyViewModel.class); mViewModel = new ViewModelProvider(requireActivity()).get(MyViewModel.class); mViewModel = new ViewModelProvider(getActivity()).get(MyViewModel.class); mViewModel = new ViewModelProvider(FirstFragment.class).get(MyViewModel.class); On the other hand, public

Create a custom view with Android Studio

蓝咒 提交于 2020-05-15 04:11:27
问题 I'm trying to make a little view in Android Studio that can drag it from right to left. This view will have 2 buttons. And when you select one of them or press outside of it, the small menu will hide again. I have been searching and I have not got any library that does something similar. I also have no idea how to do it. I can draw the small view in a separate view (layout xml) but I don't know how to add it and create the events to be opened or closed by dragging. How can I do this? Thanks.

Create a custom view with Android Studio

送分小仙女□ 提交于 2020-05-15 04:10:12
问题 I'm trying to make a little view in Android Studio that can drag it from right to left. This view will have 2 buttons. And when you select one of them or press outside of it, the small menu will hide again. I have been searching and I have not got any library that does something similar. I also have no idea how to do it. I can draw the small view in a separate view (layout xml) but I don't know how to add it and create the events to be opened or closed by dragging. How can I do this? Thanks.

Create a custom view with Android Studio

南楼画角 提交于 2020-05-15 04:10:01
问题 I'm trying to make a little view in Android Studio that can drag it from right to left. This view will have 2 buttons. And when you select one of them or press outside of it, the small menu will hide again. I have been searching and I have not got any library that does something similar. I also have no idea how to do it. I can draw the small view in a separate view (layout xml) but I don't know how to add it and create the events to be opened or closed by dragging. How can I do this? Thanks.

Bad window token, you cannot show a dialog before an Activity is created or after it's hidden

谁都会走 提交于 2020-05-09 20:06:42
问题 I am using an AppIntro library in my app. It has 3 slides. I want to ask the user something when the third slide is shown. To achieve that I am using material dialogs by afollestad. My code in the AppIntro Activity looks like that: @Override public void onNextPressed() { if(this.pager.getCurrentItem() == 2) { MaterialDialog dialog = new MaterialDialog.Builder(getApplicationContext()) .title("QR Code scannen") .content("Möchtest du den QR Code scannen oder selbst eingeben?") .positiveText(

Bad window token, you cannot show a dialog before an Activity is created or after it's hidden

醉酒当歌 提交于 2020-05-09 20:06:03
问题 I am using an AppIntro library in my app. It has 3 slides. I want to ask the user something when the third slide is shown. To achieve that I am using material dialogs by afollestad. My code in the AppIntro Activity looks like that: @Override public void onNextPressed() { if(this.pager.getCurrentItem() == 2) { MaterialDialog dialog = new MaterialDialog.Builder(getApplicationContext()) .title("QR Code scannen") .content("Möchtest du den QR Code scannen oder selbst eingeben?") .positiveText(