android-fragments

Fragment Changes when Screen is rotated

烈酒焚心 提交于 2020-02-06 02:38:38
问题 I have two fragments, FragmentCity and Fragmentnumber1. When screen orientation changes on fragmentnumber1, it goes back to FragmentCity. Does anyone know how to solve this? I appreciate it if you could show me how to solve this issue FragmentCity public class FragmentCity extends Fragment { final String[] items = new String[]{"FC1", "FC2", "FC3", "FC4","FC5" }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater

Update ViewPager's Fragments from another class:

爷,独闯天下 提交于 2020-02-03 02:07:11
问题 Following this question: How to recreate all fragments in ViewPager: I have those classes: public class ViewPagerAdapter extends FragmentPagerAdapter { private List<Fragment> fragments; /** * @param fm * @param fragments */ public ViewPagerAdapter(FragmentManager fm, List<Fragment> fragments) { super(fm); this.fragments = fragments; } /* (non-Javadoc) * @see android.support.v4.app.FragmentPagerAdapter#getItem(int) */ @Override public Fragment getItem(int position) { return this.fragments.get

Passing data between Fragments in View Pager

孤街醉人 提交于 2020-02-02 10:39:41
问题 Need help in passing data between Fragments in View Pager! We tried passing data as bundle inside Fragments. Inside the Fragment.getInstance() method and tried getting the data from the other Fragment.getArguments(). Activity Code package com.northerly.bumpr; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import

Passing data between Fragments in View Pager

半世苍凉 提交于 2020-02-02 10:38:48
问题 Need help in passing data between Fragments in View Pager! We tried passing data as bundle inside Fragments. Inside the Fragment.getInstance() method and tried getting the data from the other Fragment.getArguments(). Activity Code package com.northerly.bumpr; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import

how to select year in datepickerdialog android?

橙三吉。 提交于 2020-02-02 06:38:09
问题 I am new to Android programming. Please help. I am using Fragment that creates Material design DatePickerDialog on click of EditText . Trouble is it is set to current date (set by me). But, if user has to select the date in the past ... say, 10 years ago, user has to scroll each month which is painful. e.g. shown below: Is there a way to make your select the year? This way user can navigate to the year. 回答1: I think than that is because you don't have a minimum date or maxim date. If you try

how to select year in datepickerdialog android?

匆匆过客 提交于 2020-02-02 06:38:09
问题 I am new to Android programming. Please help. I am using Fragment that creates Material design DatePickerDialog on click of EditText . Trouble is it is set to current date (set by me). But, if user has to select the date in the past ... say, 10 years ago, user has to scroll each month which is painful. e.g. shown below: Is there a way to make your select the year? This way user can navigate to the year. 回答1: I think than that is because you don't have a minimum date or maxim date. If you try

call a method on a fragment in a ViewPager

心已入冬 提交于 2020-02-02 05:46:30
问题 All I want to do is calling a function of my Fragment's class. But I can't seem to find a way to access the instance of my fragments which are in a ViewPager. my activity's xml: <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" /> There is no so I can't call findFragmentById()

Wait until fragment has been added to the UI

泄露秘密 提交于 2020-02-02 02:48:33
问题 In my app I got to a point where, in landscape mode, I need to attach two fragments. In order to do that, the second fragment needs to wait until the first fragment has been attached (added), before it's being added. The reason for it is that the first fragment needs to execute a function that the second fragment needs. I managed to do that via a thread, but in this case it only waits the amount of time indicated, before attaching the second fragment, and in case the first fragment isn't

Android: limit fragments loading with a viewPager

半城伤御伤魂 提交于 2020-02-02 02:47:06
问题 I have 3 fragments that are managed by an FragmentPagerAdapter, set to a viewPager. I want to load fragments one by one, but when the onCreate method of FragmentActivity is executed, the 2 first fragments are executed (onCreateView method). I have tried to limit fragments loading with the setOffscreenPageLimit method but nothing change. mPagerAdapter = new MyPagerAdapter(super.getSupportFragmentManager(), fragments); pager = (ViewPager) super.findViewById(R.id.tabviewpager); pager

FCM Open Activity and call fragment when the application is not running on device

旧时模样 提交于 2020-02-01 09:35:06
问题 I'm trying to open a fragment initialized in an Activity through Firebase Cloud Messaging. The fragment call works when the application is open, but once I close the application the push notification only opens the Activity and not the fragment. MyActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //All my initial code Intent i = getIntent(); Bundle extras = i.getExtras(); if(extras != null) { String push = extras.getString("push")