Questions tagged [android-fragments]
Fragments represent reusable behaviors or portions of the user interface in an Android app.
45,190
questions
0
votes
0
answers
8
views
How to send data sent by BLE Device in a fragment to a new activity for display and plotting graph in app?
I am completely new to Android and just learned Object-oriented programming. My project requires me to build something on open-source code. I am really struggling with this special case. Two fragments ...
0
votes
0
answers
8
views
Android - Dialog listener reference gets lost on configuration change
I have Fragment which also contains a DialogFragment. In order to do something when a dialog button is pressed, I am using a DialogListener interface: that interface implements a method ...
0
votes
0
answers
4
views
How to replace ChildFragmentManager with Navigation Graph in Android
I'm working on nested fragment scenario where I'm using a fragment with BottomNavigationView and inside that main fragment I need to load new fragments and these new fragments should replace more ...
0
votes
0
answers
15
views
How to initialize data before launch a the fragment Android Studio / Java
I initialize a map in my main activity, the problem is that i need this map to initialize some variables in my launch fragment so the fragment is update before the map.
I initialize my map thanks to ...
0
votes
0
answers
8
views
How can I use my form inside fragment to add data into the database?
So I created an app for the admin where they add job services, modify, delete, update and check booked services. I created an activity and inside is a fragment with 5 tabs and each tab has its own ...
3
votes
0
answers
24
views
Created Fragment loses its Arguments inexplicably between FragmentPagerAdapter.GetItem and FragmentPagerAdapter.InstantiateItem
TL;DR:
Rarely, FragmentPagerAdapter loses Fragment.Arguments when creating new Fragment, somewhere along the call chain:
Android OS -> FragmentPagerAdapter.InstantiateItem() -> ...
0
votes
1
answer
24
views
How to change fragment and selected item in bottom navigation menu in android studio
I wanted my app to change fragment view and the selected item in bottom navigation menu. I tried doing this:
private void replaceFragment(Fragment fragment){
FragmentManager fragmentManager = ...
-1
votes
0
answers
23
views
App crashes after adding java code to Bottom Navigation home fragment
App was working perfectly before adding the java code(where i am trying to create a BMI calculator) it entered the bottom navigation but now it crashes. ...
0
votes
1
answer
18
views
Android Studio BLE: How to send Charsequence received in a fragment from serial to a new activity for display and plotting graph in app?
I am completely new to Android Studio and just learned Object-oriented programming. My project requires me to build something on open-source code. I am really struggling with this special case. ...
0
votes
0
answers
9
views
How can the Android OS identify AndroidX fragments if they are obfuscated?
I am doing a reverse-engineering work related to Android fragments. I found out in many apks (decompiled with apktool, dexToJar, ...), the androidx.fragment.app.Fragment class is obfuscated. In most ...
0
votes
0
answers
14
views
ActionBarDrawerToggle stops working on fragment change
I have a HomeActivity which initiates the ActionBarDrawerToggle as follows:
private fun initDrawer() {
val toolbar = binding.fragmentHomeContainerView.findViewById<MaterialToolbar>(R....
0
votes
0
answers
8
views
Background color isnt showing in android studio?
I have added a color picker to my simple note app. Right now the problem is when the user clicks to update the note then the background color isn't showing. How can I fix that?
...........................
0
votes
1
answer
21
views
I cant refrence the adapter
I have an adaptor that I initiate in onCreate and a listview that I initiate in onViewCreated
I'm trying to setAdapter but I can't pass the adapter in onViewCreated.
Ive tried multiple things like ...
-1
votes
1
answer
19
views
ListView Array Adapter error"None of the following functions can be called with the arguments supplied."
I'm trying to create a fragment with a ListView with the id=lv and the ArrayAdapter doesn't seem to work
this is the fragment code
class Istoric : Fragment() {
var array = arrayOf("item1"...
-1
votes
0
answers
29
views
How to call a DialogFragment from a Fragment
Very simple, I try to call a multiple choice DialogFragment that I made, which works in any activity, but not in a fragment, hopefully you can help me!
Here is the error message:
E/AndroidRuntime: ...
0
votes
0
answers
9
views
Is there a way to get fragment from dynamic delivery in android?
I'm trying to make an application where there are 5 fragments in an activity. The first and second fragments are installed in base module. I would like to download the third, fourth and fifth fragment ...
0
votes
2
answers
16
views
ViewPager2 doesn't show Fragments
I am trying to implement ViewPager2 in my application and this is not the first time I am doing it but now it is not working.
I've been trying to find a solution for a couple of hours and trying ...
0
votes
1
answer
25
views
How to get the full name of fragments using "adb shell dumpsys activity"
For a testing purpose, I use adb shell dumpsys activity <activity_name> to dump the information of the fragments in the foreground activity.
The problem is that the dumped fragment name only ...
0
votes
0
answers
12
views
Fragment switching causes fragment to recreate itself instead
So for some reason I am unable to switch between to specific fragments and when it should switch between fragments it keeps recreating the original fragment instead of replacing it with the intended ...
0
votes
1
answer
31
views
Google Map won't launch
I'm writing you this hoping that you can help me. For some reason, my app won't launch google Maps instead when I click on the button it sends me back to the previous activity/page.
When I press that ...
1
vote
0
answers
10
views
Fragments vs. Activities: What is a better practise: to have 2 fragments or 2 Activities in Android Studio Application
I would like to know what is a better practise: to have 2 fragments or 2 Activities in Android Studio Application and the reason why ? In which case 2 fragments and in which 2 activities ?
0
votes
0
answers
10
views
How to pass data from android Tabs to Tabs with switching?
I'm trying to switch into second tab from first tab when first tab's recycler view item is get clicked. I also want to pass data from first tab to second tab.
When i do pass data using interface, my ...
0
votes
0
answers
10
views
i have created a method setFragment on which i am trying to replace fragment by passing object of fragment. class
HomeActivity
public class HomeActivity extends AppCompatActivity {
BottomNavigationView bottomNavigationView;
Context context;
private OrderFragment orderFragment;
private VideoFragment videoFragment;
...
0
votes
1
answer
22
views
how to get the position of a click in recycler view and use in fragment to pass it to an activity
my adapter program
class MusicAdapter(private val context: Homefragment, private val musicList: ArrayList<Music>, var listener:OnItemClick? = null, ) : RecyclerView.Adapter<MusicAdapter....
0
votes
1
answer
16
views
How to not show bottom nav bar in other fragments except the section fragments?
I have a bottom nav bar with 4 section fragment attached. In every fragment there is something by clicking that I am going to other fragment which are not section fragment. I want to show bottom nav ...
0
votes
0
answers
18
views
Why an IllegalStateException is thrown inside Google Play In-App Review listeners when calling findNavController or requireActivity?
We are using the Google Play In-App Reviews API.
Since our last update to the Play Store (last week), we started receiving the following exception java.lang.IllegalStateException, inside of the ...
-1
votes
0
answers
35
views
Android navArgs and bundle arguments clear on back
I use navArgs and also I have read that I should use old school bundle in my case.
Android navArgs clear on back
I have the same issue as above:
I have fragment A that opens fragment B with navArgs, ...
0
votes
0
answers
36
views
I'm trying to pass an ArrayList<CustomObject> into a fragment activity> in Kotlin. How would I do that?
I assume it should look something like this?
Fragment1.kt
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view....
0
votes
1
answer
29
views
Kotlin - lateinit property fragmentHomeBinding has not been initialized
I am working on a kotlin application that contains fragments. I am converting an app I created using activity to fragments but I am having an issue. I get an error when running the app that the ...
-2
votes
0
answers
18
views
when I run the program, it runs without error, but when I receive information [closed]
when I run the program, it runs without error, but when I receive information, it receives an error message in receiving information. Can anyone help me?
I checked the PhP code and had no problem if ...
0
votes
1
answer
23
views
Close bottomsheet and when open it again the changes will still be there
I made a bottomsheet with a couple of items, I make some changes into it and apply (it will close the bottomsheet), but when I open it again the bottomsheet resets, how can I keep the values that I ...
0
votes
1
answer
17
views
Fragment Transition Animation
I am trying to animate 2 Fragments [Splash Fragment , Fragment 1]
While the transition there is a white blank screen for small milli Secs which should not be there
The code of Animation Resource File :...
0
votes
2
answers
20
views
Android Broadcast not triggering Receiver
I've been trying to figure out this bug for days...
Issue: sendBroadcast(intent) isn't triggering BroadcastReceiver.
My code successfully starts a foreground service... This is supposed to broadcast ...
-4
votes
0
answers
21
views
Is there any source code to implement recycler view inside fragment from api? [closed]
I like to implement recycler view inside a fragment. The data should me fetch from mysql database.
Does anybody can share the a simple example source code?
-1
votes
0
answers
50
views
I got stuck with fragments in Android [closed]
I wish to have a button named "HELP" in MainActivity which will, beyond that the Activity is working as a stand alone does,
(currently in MainActivity.java and activity_main.xml)
switches to ...
0
votes
1
answer
33
views
How to handle bottom navigation bar's fragments?
I have four fragments attached in my bottom nav bar. Now I am trying to go from one this fragments to any other fragment by clicking on a cardview. This is working perfectly but when I am going to ...
0
votes
0
answers
12
views
Fragment to Activity Shiffting
I am using this as my code it is a fragment as
I want to add OnClickListener on my button Login
How to do it and what I should do so that it works. New at Java day -03.
Do I have to import any classes?...
-1
votes
0
answers
21
views
How to develop and structure an Android app to fill forms using fragments
I'm starting to develop a form filler application in Android Studio.
I have about 10 types of forms and each of them contains about 8 pages. I thought of developing the application using fragments and ...
0
votes
2
answers
20
views
How do i use findViewById in a fragment instead of an activity?
So I'm building this calculator and I used activities but now I have to use fragments instead.
I had these buttons implemented but now that I've moved them in a fragment I cant use findViewById. How ...
0
votes
1
answer
16
views
Create fragment in viewpager adapter when tab selected
There are two fragments inside viewPager. When the main fragment load the location permission code on the second fragment that work. Want that fragmen work when click the second tab. So I think I need ...
0
votes
0
answers
7
views
How can I add something to the savedinstancestate of an already destroyed fragment?
Simple question. If a fragment is still existing then I can set the fields of that fragment so when it gets destroyed they will be put into the savedInstanceState. But if the fragment was already ...
0
votes
0
answers
28
views
how to access variable declared in onCreate method from onCreateView method and
I have a java application that contains 2 fragments. In the first fragment I get the Facebook name and email as well as a random alias that is generated in the app. The idea is to be able to send the ...
0
votes
1
answer
37
views
Android getActivity() Context Goes Stale Over Time in PopupWindow
I have an app that uses a popupWindow for user chat. It is launched from a Fragment, and the supplied context is getActivity(). I will be typing in the popupWindow's multilineEditText and, after about ...
0
votes
1
answer
16
views
Move to one fragment to another fragment of different container activity
I have an container activity which will contain the fragments which will be added to this container when my bottom nav bar is navigating. Now I want to go to one of this fragment to another fragment ...
0
votes
0
answers
14
views
No view found for id 0x7f0a007d (com.fahim69.bazaarapp:id/category_container) for fragment FruitCategory{adff339}
I am developing an ecommerce app where in an activity there is a bottom nav bar and a container the fragments which will be show while navigating using nav bar. All are working fine but when I tried ...
1
vote
0
answers
30
views
Reusing a fragment with different task
I've got some fragments with a group of buttons inside them which are reused across my app,
for example: fragment1withbuttons
fragment2withbuttons
Depending on a state in which my app is in they need ...
0
votes
1
answer
30
views
AlertDialog "onClick" method not working properly
I currently have an alert dialog that is being displayed on a fragment. The dialog displays to the user with no issues, but the "setPositiveButton" and "setNegativeButton" are not ...
0
votes
2
answers
23
views
Errors in connection of CameraFragment.kt with xml
I need help please, i'm getting errors in fragment.kt in process of getting a camera set up
**
//fragmentcamera.xml
**
**<?xml version="1.0" encoding="utf-8"?>
<...
0
votes
1
answer
32
views
My findViewById is not working. in my fragment
My findViewById is not working. it does not link...
////my fragment.contacts.xml
*<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas....
0
votes
0
answers
15
views
How to replace fragments using NavigationGraph in NestedFragments
Below I have mentioned a hierarchy of multiple nested fragments where I need to replace and add new fragments as child fragments. So I have completed to show BottomNavigationView but whenever I tried ...