android-fragments

My fragments keep recreating whenever I reclick or navigate to the next fragment

大兔子大兔子 提交于 2020-12-01 10:15:56
问题 I have implemented the new architecture component on my android app, but unfortunately handling the states of these fragments has become a nightmare for me. Whenever I press the icon of the fragment, the fragment is recreated every time I navigate. How can I handle this or rather save these fragments states? Here is my main activity handling the five fragments: public class MainActivityCenterofInformation extends AppCompatActivity { BottomNavigationView bottomNavigationView; @Override

How to save data by using SharedPreferences in a Fragment

為{幸葍}努か 提交于 2020-11-30 02:13:35
问题 I'm having a problem with saving data permanently. It should be simple, I'm sending data to another Fragment and it works perfectly, however, I have no idea how to save data. I tried something, but I was wondering if you could help me out. In my code, I'm sending a data to another Fragment by pushing a Button. So this is the code: package com.example.mskydraw.notetech; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4

How to save data by using SharedPreferences in a Fragment

試著忘記壹切 提交于 2020-11-30 02:13:06
问题 I'm having a problem with saving data permanently. It should be simple, I'm sending data to another Fragment and it works perfectly, however, I have no idea how to save data. I tried something, but I was wondering if you could help me out. In my code, I'm sending a data to another Fragment by pushing a Button. So this is the code: package com.example.mskydraw.notetech; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4

How to save data by using SharedPreferences in a Fragment

风流意气都作罢 提交于 2020-11-30 02:12:57
问题 I'm having a problem with saving data permanently. It should be simple, I'm sending data to another Fragment and it works perfectly, however, I have no idea how to save data. I tried something, but I was wondering if you could help me out. In my code, I'm sending a data to another Fragment by pushing a Button. So this is the code: package com.example.mskydraw.notetech; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4

Android fragment is being put on top of the previous one when coming back from background

怎甘沉沦 提交于 2020-11-29 19:31:30
问题 In my MainActivity, I have three fragments. There is also a BottomNavigationView that handles what fragment to show. This is what I have in my MainActivity's OnCreate: fragmentManager.beginTransaction().add(R.id.content_main, mTrendingFragment, "3").hide(mTrendingFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mFavoriteFragment, "2").hide(mFavoriteFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mUpcomingViewPagerFragment, "1").commit

Android fragment is being put on top of the previous one when coming back from background

∥☆過路亽.° 提交于 2020-11-29 19:30:19
问题 In my MainActivity, I have three fragments. There is also a BottomNavigationView that handles what fragment to show. This is what I have in my MainActivity's OnCreate: fragmentManager.beginTransaction().add(R.id.content_main, mTrendingFragment, "3").hide(mTrendingFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mFavoriteFragment, "2").hide(mFavoriteFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mUpcomingViewPagerFragment, "1").commit

Android fragment is being put on top of the previous one when coming back from background

醉酒当歌 提交于 2020-11-29 19:26:06
问题 In my MainActivity, I have three fragments. There is also a BottomNavigationView that handles what fragment to show. This is what I have in my MainActivity's OnCreate: fragmentManager.beginTransaction().add(R.id.content_main, mTrendingFragment, "3").hide(mTrendingFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mFavoriteFragment, "2").hide(mFavoriteFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mUpcomingViewPagerFragment, "1").commit

Android fragment is being put on top of the previous one when coming back from background

那年仲夏 提交于 2020-11-29 19:25:26
问题 In my MainActivity, I have three fragments. There is also a BottomNavigationView that handles what fragment to show. This is what I have in my MainActivity's OnCreate: fragmentManager.beginTransaction().add(R.id.content_main, mTrendingFragment, "3").hide(mTrendingFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mFavoriteFragment, "2").hide(mFavoriteFragment).commit(); fragmentManager.beginTransaction().add(R.id.content_main, mUpcomingViewPagerFragment, "1").commit

Android barcode, onActivityResult not calling

流过昼夜 提交于 2020-11-25 03:56:48
问题 I am using Zxing barcode scan. Like most of the issues I am facing the same one. That It's not hitting the onActivityResult . I am using this tutorial Layout <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" android:padding="2dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left|center_vertical" android:text="Smart MSN #" />