android-fragments

Invoking intent from a fragment

a 夏天 提交于 2020-04-30 07:37:14
问题 I have a fragment public class TwitterFragment extends Fragment implements OnClickListener {} From this fragment I am invoking an intent as: Intent intent = new Intent(this, WebViewActivity.class); where, public class WebViewActivity extends Activity { But Invoking intent is giving error: Error:(214, 33) error: no suitable constructor found for Intent(TwitterFragment,Class<WebViewActivity>) constructor Intent.Intent(String,Uri) is not applicable (argument mismatch; TwitterFragment cannot be

Fragment stucks when, in OnCreateView, a Bitmap (path from SharedPreferences) is set by onBindViewHolder

主宰稳场 提交于 2020-04-30 06:31:33
问题 I will try to be more specific about my issue. I start saying I've already seen this question that shows the same kind of problem, I guess, but I didn't really understand the right solution. Note: I have created the drawer activity and all navigation dependencies from a template in creating new project step Initially, I found that when, in ShowProfileFragment, I tried to update the header of the navigation drawer, the same issue happened, so when I put that if statement (see code below) to

Preserve view with data of recyclerview list in NavController Fragments

旧巷老猫 提交于 2020-04-18 05:30:48
问题 What approach should be taken to preserve (data & view rendering) of recyclerview list in 2 tabs present within a fragment, which is part of androidx.navigation NavController ? Activity --> Fragment A --> Fragment B (with 2 tabs) --> Fragment C (and back till activity) Each tab of Fragment B has accordion type view (multiple active), made from 1 ParentRecycler view & ChildRecycler view (number of parent recycler view times) (The recycler view list are not bound to change on previous next

Preserve view with data of recyclerview list in NavController Fragments

▼魔方 西西 提交于 2020-04-18 05:29:27
问题 What approach should be taken to preserve (data & view rendering) of recyclerview list in 2 tabs present within a fragment, which is part of androidx.navigation NavController ? Activity --> Fragment A --> Fragment B (with 2 tabs) --> Fragment C (and back till activity) Each tab of Fragment B has accordion type view (multiple active), made from 1 ParentRecycler view & ChildRecycler view (number of parent recycler view times) (The recycler view list are not bound to change on previous next

Fragment testing error: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class <unknown>

早过忘川 提交于 2020-04-17 22:45:49
问题 I am trying to test a fragment, following these instructions: https://developer.android.com/training/basics/fragments/testing However I am getting the following crash when calling launchFragmentInContainer from my test. Stacktrace: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class <unknown> Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown> Caused by: java.lang.reflect

Android Studio not showing available dependency update

梦想与她 提交于 2020-04-17 18:43:53
问题 I am on Android Studio 3.6.1, in my app build.gradle I have e.g. implementation 'androidx.fragment:fragment-ktx:1.2.2' There is version 1.2.3 since March 18th, yet no update hint is shown, neither when I hover over the dependency nor in Module settings -> suggestions . What could be the reason that the update isn't shown? Can I somehow trigger Android Studio manually to search for dependency updates and check when Android Studio did so last time? 回答1: You can manually check for dependency

Android Navigation - After deeplink navigation to second fragment, open first fragment in the same graph, but from another navigation graph

倾然丶 夕夏残阳落幕 提交于 2020-04-16 02:58:25
问题 In my navigation, I have something like this: When I open registrationFragment (in entry_graph) from a deep-link, and finish registration, I am navigated to main_graph (MainFragment). From there, I can access to menuFragment and click on logOut, which calls: MainFragmentDirections.actionMainFragmentToEntryFragment() It opens the registrationFragment instead of loginFragment. I do not expect that since loginFragment is the home fragment on that graph. When I have similar navigation but not

Android Navigation - After deeplink navigation to second fragment, open first fragment in the same graph, but from another navigation graph

淺唱寂寞╮ 提交于 2020-04-16 02:58:13
问题 In my navigation, I have something like this: When I open registrationFragment (in entry_graph) from a deep-link, and finish registration, I am navigated to main_graph (MainFragment). From there, I can access to menuFragment and click on logOut, which calls: MainFragmentDirections.actionMainFragmentToEntryFragment() It opens the registrationFragment instead of loginFragment. I do not expect that since loginFragment is the home fragment on that graph. When I have similar navigation but not

add an actionbar for each fragment

吃可爱长大的小学妹 提交于 2020-04-16 02:41:25
问题 Suppose I have 4 fragments that I put in mainActivity, I want to create different actionbar different in each frgament. When I press fragment 1 then the actionBar appears fragment 1, when I press the two fragment that appears actoinbar belonging to fragment 2 01-02 20:12:33.700 15035-15035/src.go_letskerja E/AndroidRuntime: FATAL EXCEPTION: main Process: src.go_letskerja, PID: 15035 java.lang.NullPointerException at src.go_letskerja.Fragment.OtherFragment.onCreateView(OtherFragment.java:26)

How to set menu items in a fragment toolbar?

房东的猫 提交于 2020-04-14 03:47:23
问题 I have a fragment in my Activity and the fragment has its own toolbar. Like this: Image Here is the layout of the fragment: <FrameLayout 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="com.hometsolutions.space.Fragments.ControlFragment"> <LinearLayout android:layout_width="match_parent" android