android-fragments

Why does click Event in Fragment takes back to the last activity without any such instruction given in the setOnClickListener in Android?

本小妞迷上赌 提交于 2020-05-17 07:04:34
问题 This question is an extension to previous question over here. First Question So the logged in user and chatbuddy names are not returning null any more and data is being inserted in firebase as well. However the setOnClickListener action takes back to previous UsersList.java activity even though no such Intent given in sendImgView.setOnClickListener() function. UserList.java relevant code takes to ChatActivity as you can see and also i finish() it on click- usersList.setOnItemClickListener(new

Android Fragment display a loading while rendering layout

守給你的承諾、 提交于 2020-05-17 05:49:25
问题 Let's say I've got an Activity with only a FrameLayout ( I've also try with the new FragmentContainerView ) so I will be loading Fragments on it. Let's assume I've got two Fragments: fragA and fragB , I will first load fragA and with a button, present in that fragment, replace it with fragB . I've define a function on my Activity so I can load a new Fragment on the container: public void loadFragment(Fragment fragment) { FragmentTransaction fragTrans = getSupportFragmentManager()

Navigation Architecture Component - BottomNavigationView with Login Screen

徘徊边缘 提交于 2020-05-16 05:56:11
问题 I have my MainActivity setup which looks like this : <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.host.HostActivity"> <fragment android:id="@+id/mainNavigationFragment" android:name="androidx.navigation.fragment.NavHostFragment" android

Navigation Architecture Component - BottomNavigationView with Login Screen

自闭症网瘾萝莉.ら 提交于 2020-05-16 05:54:20
问题 I have my MainActivity setup which looks like this : <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.host.HostActivity"> <fragment android:id="@+id/mainNavigationFragment" android:name="androidx.navigation.fragment.NavHostFragment" android

Double back press to exit from fragment

微笑、不失礼 提交于 2020-05-15 09:50:29
问题 Since question is quite similar but I didn't found an exact answer to it. I tried the answer on the link below but it is not working!! Android Double Back Press to close the app having fragments Here are my codes: public interface OnBackPressedListener { void onBackPressed(); } Now the fragment: public class HomeFragment extends Fragment implements View.OnClickListener, OnBackPressedListener{ boolean doubleBackToExitPressedOnce = false; @Override public void onBackPressed() { //Checking for

What ViewModelStoreOwner to use for ViewModelProvider in Fragment?

做~自己de王妃 提交于 2020-05-15 07:56:45
问题 I've creating a test activity that updates some text in my MyViewModel. I'd like to observe these changes in a Fragment , but when I use MyViewModel myViewModel = new ViewModelProvider(this).get(MyViewModel.class); it gives me a different instance of MyViewModel than that used in the activity, which results in my onChanged() callback in the fragment not being called. Only when I modify that same fragment code to HomeViewModel homeViewModel = new ViewModelProvider(getActivity()).get

Lag when switching tabs in BottomNavigationView

拜拜、爱过 提交于 2020-05-15 05:43:05
问题 I have an Activity that contains a BottomNavigationView, and this bottomnav helps the activity to display three fragments. These fragments load well, and I use an AsyncTask to do every heavy operation, while in the UI thread, I show a ProgressBar until everything loads. There is a weird behaviour with my fragment: The first time I load the fragment it takes some time to actually display it, instead of displaying it instantly with a progressbar. This thing only happens the first time, and only

Lag when switching tabs in BottomNavigationView

房东的猫 提交于 2020-05-15 05:42:06
问题 I have an Activity that contains a BottomNavigationView, and this bottomnav helps the activity to display three fragments. These fragments load well, and I use an AsyncTask to do every heavy operation, while in the UI thread, I show a ProgressBar until everything loads. There is a weird behaviour with my fragment: The first time I load the fragment it takes some time to actually display it, instead of displaying it instantly with a progressbar. This thing only happens the first time, and only

How can I manage fragment and activity considering its creation orders?

左心房为你撑大大i 提交于 2020-05-14 13:00:10
问题 What I would like to do I would like to call Activity from Fragment to realize both transitions among fragments and activities simultaneously in an Android app. I have succeeded to call one specific method on activity file from fragment file, but I have trouble with calling an entire activity from a fragment. SampleFragment - MainActivity's fragmentMethod() is called once the button is clicked on the page Sample1Fragment - FormActivity is called once the button is clicked on the page

Send data to fragment with FragmentTransaction

為{幸葍}努か 提交于 2020-05-11 05:58:28
问题 I'm in my fragment class calling this: @OnClick(R.id.blockedLinkLayout) public void onBlockedClick(){ final FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.content, new SettingsBlockedUsersFragment(), FRAGMENT_TAG); ft.commit(); } And it just replace my current fragment with chosen one. And my question is, how can I send some data (e.g. String value) from my parent fragment to my child fragment using FragmentTransaction? 回答1: Just pass them in a bundle as