android-fragments

Bottom Navigation bar with fragments

梦想的初衷 提交于 2020-03-21 22:25:10
问题 I have a bottom navigation bar in my Main Activity. By clicking on one of the tabs in my bottom navigation, I want to change the fragment in the view. I have the following code: Main Activity: public class StartActivity extends AppCompatActivity { SwiftFragment swiftFragment; FrameworksFragment frameworksFragment; FrameLayout content; android.support.v4.app.FragmentManager fragmentManager; private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new

popBackStack causes calling oncreateView of fragment again and again

南楼画角 提交于 2020-03-18 03:43:17
问题 I have 3 fragment A, B,C.I wrote piece of code for replacing them and maintaining backstack: public void addFragment(Fragment fragmentToAdd, String fragmentTag) { FragmentManager supportFragmentManager = getSupportFragmentManager(); Fragment activeFragment = getActiveFragment(); FragmentTransaction fragmentTransaction = supportFragmentManager .beginTransaction(); if (null != activeFragment) { fragmentTransaction.hide(activeFragment); } fragmentTransaction.replace(R.id.layout_child_activity,

Android Navigation Component Not Displaying Fragment

▼魔方 西西 提交于 2020-03-16 06:22:27
问题 I'm trying to implement the new Android Navigation Component in an existing app. I have 2 fragments that are identical except for their name. When I set the startDestination to fragment2, the fragment seems to be shown correctly. When the startDestination is set to fragment1, I don't see the inflated view but I do see the "Fragment 1 created" toast. What am I doing incorrectly? class Fragment1 : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,

Exception when using data binding in fragment: “The specified child already has a parent. You must call removeView() on the child's parent first”

半腔热情 提交于 2020-03-16 05:39:51
问题 Android Studio 3.1, java 1.8 I try to use data binding: Here settings.xml layout: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> <variable name="handler" type="com.myproject.SettingsFragment" /> </data> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent">

Exception when using data binding in fragment: “The specified child already has a parent. You must call removeView() on the child's parent first”

百般思念 提交于 2020-03-16 05:38:25
问题 Android Studio 3.1, java 1.8 I try to use data binding: Here settings.xml layout: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> <variable name="handler" type="com.myproject.SettingsFragment" /> </data> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent">

How to Refresh ListView in Fragment that is filled with BaseAdapter?

倾然丶 夕夏残阳落幕 提交于 2020-03-14 09:22:34
问题 I want to Refresh a ListView in a Fragment when a Dialog is closed. Until now the refresh only works when I restart the app and I don't really know why. Here are the classes: This is the Fragment with the ListView on it, that i want to refresh, when the Dialog is closed. public class RegisterListFragment extends Fragment { public static final String TAG = "RegisterListFragment"; RegisterListAdapter adapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,

How to Refresh ListView in Fragment that is filled with BaseAdapter?

折月煮酒 提交于 2020-03-14 09:16:51
问题 I want to Refresh a ListView in a Fragment when a Dialog is closed. Until now the refresh only works when I restart the app and I don't really know why. Here are the classes: This is the Fragment with the ListView on it, that i want to refresh, when the Dialog is closed. public class RegisterListFragment extends Fragment { public static final String TAG = "RegisterListFragment"; RegisterListAdapter adapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,

Is it possible to pass arguments to a fragment after it's been added to an activity?

China☆狼群 提交于 2020-03-12 14:26:01
问题 I know that when you're first instantiating a fragment you can pass arguments using setArguments(Bundle) and retrieve them in the fragment using getArguments() . However, in my app I have fragments that will be detached and attached several times after they've been added to an activity. On re-attach, I may need to pass a fragment an argument to modify its content prior to reattaching it. I can use setArguments the first time I display the fragment, but on subsequent occasions that won't work.

Getting an adapter instance from a ViewHolder

我与影子孤独终老i 提交于 2020-03-06 03:33:30
问题 I'm trying to create a contextual floating menu with the information (position,id,etc) of the selected menu to be accessible inside the overridden method onContextItemSelected in my Fragment. So I have a custom adapter extending from RecyclerView.Adapter<ViewHolder> and a custom ViewHolder class in separate file. I registered my click listener and provided its handler inside the custom ViewHolder class. Since I need to send the ViewHolder information back to my Fragment when the event is

No view found for id 0x7f0800c4 for fragment

旧街凉风 提交于 2020-03-05 04:41:07
问题 I get this error when I am trying to replace the parent fragment ( SearchFragment ) from the child fragment ( ClassroomsTab ) in a swipe tab viewPager . Basically what I am trying to achieve is have a swipe tab menu with multiple buttons in each child fragment that closes the swipe tab menu and open a different existing fragment. The SearchFragment is in a Navigation Drawer activity and so is the destination fragment of the buttons. From what I have read, a solution to this issue is to