android-fragments

mActivity from Fragment.onAttach() not retained

不问归期 提交于 2020-02-08 09:09:08
问题 I have setup a Observable/Subscriber with RxJava. The Observable is created in MainActivity. The Subscriber is a android.support.v4.app.Fragment called MyFragment. The Observable gets data from RESTful service and stores the data in a SQLite db on the device. This works. When its work is done, which takes 4 or 5 seconds such that MyFragment has already processed onCreate() , onCreateView() etc., the subscriber, MyFragment, is notified via its implemented onNext() method (this works) and is

How to update the content of view pager once it is initialized?

人盡茶涼 提交于 2020-02-08 07:20:51
问题 I have a view pager in the MainActivity , this view pager contains two tabs RecentFeed and SavedFeed both uses the same FeedFragment as both has same layout Now I want to update the contents of these fragments when a new gcm message is recieved or there occurs a change in my database here is what have done so far : I created a changelistening interface as follows- public interface OnDatabaseChangeListener { void onChange(); } Then used this in helper class to notify changes as follows private

How to update the content of view pager once it is initialized?

白昼怎懂夜的黑 提交于 2020-02-08 07:20:08
问题 I have a view pager in the MainActivity , this view pager contains two tabs RecentFeed and SavedFeed both uses the same FeedFragment as both has same layout Now I want to update the contents of these fragments when a new gcm message is recieved or there occurs a change in my database here is what have done so far : I created a changelistening interface as follows- public interface OnDatabaseChangeListener { void onChange(); } Then used this in helper class to notify changes as follows private

How to update the content of view pager once it is initialized?

不打扰是莪最后的温柔 提交于 2020-02-08 07:19:21
问题 I have a view pager in the MainActivity , this view pager contains two tabs RecentFeed and SavedFeed both uses the same FeedFragment as both has same layout Now I want to update the contents of these fragments when a new gcm message is recieved or there occurs a change in my database here is what have done so far : I created a changelistening interface as follows- public interface OnDatabaseChangeListener { void onChange(); } Then used this in helper class to notify changes as follows private

Clicking CardView to load a fragment

孤人 提交于 2020-02-08 01:33:08
问题 I'm having trouble with implementing clickable cards with my RecyclerView. I want to get the position of which card was clicked and then load the proper fragment. I did take a look at this post and spent almost 30 minutes trying to make sense of the code and implementing it myself but I gave up when I realized how many mistakes were in the snippet. Here is my adapter class. public class RVAdapter extends RecyclerView.Adapter<RVAdapter.PersonViewHolder> { public static CardView cv; public

Clicking CardView to load a fragment

懵懂的女人 提交于 2020-02-08 01:30:14
问题 I'm having trouble with implementing clickable cards with my RecyclerView. I want to get the position of which card was clicked and then load the proper fragment. I did take a look at this post and spent almost 30 minutes trying to make sense of the code and implementing it myself but I gave up when I realized how many mistakes were in the snippet. Here is my adapter class. public class RVAdapter extends RecyclerView.Adapter<RVAdapter.PersonViewHolder> { public static CardView cv; public

Recyclerview item onClick to open a fragment from Main Activity Fragment

[亡魂溺海] 提交于 2020-02-07 05:24:25
问题 i have 4-5 fragments on MainActivity and on host fragment i have a recyclerview. on each item of recycler i have to open a fragment out of 4 more and kill the current fragment on which recycler is placed. i couldnt achieve this. here is my MainActivity where all fragments are placed and host fragment is homefragment where recycler is placed and i want to move from homefragment to another fragment when 0th item clicked public class MainActivity extends AppCompatActivity { private

Passing a value from Activity to Fragment in Kotlin

时光毁灭记忆、已成空白 提交于 2020-02-06 11:31:58
问题 I created a bottom navigation activity in my project, which contains one activity and two fragments. In Main Activity I have value stored in a variable but if I pass the value to the fragments then I am getting NullPointer Exception error. I am using kotlin in my project and any help is appreciated. Expectation Get Value into Fragment from MainActivity. MainActivity--->TestOneFragment Language Used Kotlin Main Activity class Test : AppCompatActivity(), BottomNavigationView

Passing a value from Activity to Fragment in Kotlin

…衆ロ難τιáo~ 提交于 2020-02-06 11:28:53
问题 I created a bottom navigation activity in my project, which contains one activity and two fragments. In Main Activity I have value stored in a variable but if I pass the value to the fragments then I am getting NullPointer Exception error. I am using kotlin in my project and any help is appreciated. Expectation Get Value into Fragment from MainActivity. MainActivity--->TestOneFragment Language Used Kotlin Main Activity class Test : AppCompatActivity(), BottomNavigationView

Passing a value from Activity to Fragment in Kotlin

Deadly 提交于 2020-02-06 11:24:27
问题 I created a bottom navigation activity in my project, which contains one activity and two fragments. In Main Activity I have value stored in a variable but if I pass the value to the fragments then I am getting NullPointer Exception error. I am using kotlin in my project and any help is appreciated. Expectation Get Value into Fragment from MainActivity. MainActivity--->TestOneFragment Language Used Kotlin Main Activity class Test : AppCompatActivity(), BottomNavigationView