android-fragments

Text to speech in fragment

假装没事ソ 提交于 2021-01-28 21:28:36
问题 Getting errors on, sorry only beginner. All help would be great. 05-31 21:49:16.077: E/AndroidRuntime(655): FATAL EXCEPTION: main 05-31 21:49:16.077: E/AndroidRuntime(655): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appal.song/com.appal.song.MainActivity}: java.lang.NullPointerException 05-31 21:49:16.077: E/AndroidRuntime(655): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956) 05-31 21:49:16.077: E/AndroidRuntime(655): at android.app

how to open multiple instances of a fragment in navigation component?

两盒软妹~` 提交于 2021-01-28 08:01:55
问题 I working on a social media App. when user click on a post, a new fragment open and some related post showing under it. if user click on a related post, new instance of that fragment must open and show clicked post and related posts under it. this page also have this behavior. each page must add to back stack. for using navigation component, in this case destination fragment is current fragment with different argument. can do this in navigation component? 回答1: we can open multiple instace of

How to work with preference in single activity design using navigation component?

◇◆丶佛笑我妖孽 提交于 2021-01-28 06:20:27
问题 I want to migrate to single activity design using navigation component. I am using one activity and others are fragment. For some screens, I have only layouts, no preference. No problems to inflate those in fragment. But i faced problem when i try to work with preference. My requirements is: I need to inflate a toolbar and preference list in a fragment. My approaches: Add preference using this following code. SettingFragment.java @Override public void onCreatePreferences(Bundle

API data in kotlin fragment

独自空忆成欢 提交于 2021-01-28 06:01:46
问题 I am trying to use Drawer activity , seems that it has 3 files to just show simple text as This is home Fragment :| Anyway, I have tracked back all those files and found fragment_home.xml , HomeFragment.kt and HomeViewModel.kt Question How should I call for API data trough fragments? Code my code Based on android studio documentation this is the code that I should use in order to get my api data. val textView = findViewById<TextView>(R.id.TextView) // Instantiate the RequestQueue. val queue =

RecyclerView with StaggeredGridLayoutManager in ViewPager, arranges items automatically when going back to fragment

◇◆丶佛笑我妖孽 提交于 2021-01-28 04:55:22
问题 I am using Navigation component in my App, using google Advanced Sample(here). my problem is when going back to a fragment, t he scrolling position does not lost but it rearranges items and moves highest visible items so that top of those item align to top of recyclerview. please see this: before going to next fragment: and after back to fragment: this problem is matter because some times clicked item goes down and not seen until scroll down. how to prevent this behavior? please consider:

Changing Locale at runtime not effecting fragments

老子叫甜甜 提交于 2021-01-28 03:05:47
问题 When user changes language i execute following code,it works fine for the present fragment in the activity, but if i go to other fragment, it partially updates the language, some strings gets updated and shows old language, and most importantly the date does not changes in inner fragments,and other activities. I tested this in nougat, marshmallow and oreo, and its happening in all of OS. When user changes the language i execute following. LocaleHelper.setLocale(getApplicationContext(),

How to handle click in a nested RecyclerView

末鹿安然 提交于 2021-01-27 10:50:20
问题 Can someone explain the logic on how to handle this matter: I have a fragment that after a WebSocket call inflates 2 Recyclerviews. Child Recyclerview is nested to Parent Recyclerview and the parent adapter calls the child adapter. I want to put an Interface for a click listener which handles the click in the Child Items in the Fragment. Where should I put the interface and which class should implement it? 回答1: What you're trying to do has been done multiple times. There are various

How to handle click in a nested RecyclerView

扶醉桌前 提交于 2021-01-27 10:49:55
问题 Can someone explain the logic on how to handle this matter: I have a fragment that after a WebSocket call inflates 2 Recyclerviews. Child Recyclerview is nested to Parent Recyclerview and the parent adapter calls the child adapter. I want to put an Interface for a click listener which handles the click in the Child Items in the Fragment. Where should I put the interface and which class should implement it? 回答1: What you're trying to do has been done multiple times. There are various

How to detect when back button pressed in fragment android?

余生颓废 提交于 2021-01-27 04:06:56
问题 I have project with navigation drawer with fragment, with 5 menu, the problem is when i go to menu 4 and the i press the back button the app closed, but i need the app back to first menu which is all the menu in fragment. This is code for Main Activity (Navigation Drawer) public class MainActivity extends AppCompatActivity{ DrawerLayout mDrawerLayout; NavigationView mNavigationView; FragmentManager mFragmentManager; FragmentTransaction mFragmentTransaction; @Override protected void onCreate

How to detect when back button pressed in fragment android?

北慕城南 提交于 2021-01-27 04:06:47
问题 I have project with navigation drawer with fragment, with 5 menu, the problem is when i go to menu 4 and the i press the back button the app closed, but i need the app back to first menu which is all the menu in fragment. This is code for Main Activity (Navigation Drawer) public class MainActivity extends AppCompatActivity{ DrawerLayout mDrawerLayout; NavigationView mNavigationView; FragmentManager mFragmentManager; FragmentTransaction mFragmentTransaction; @Override protected void onCreate