私のフラグメントの1つにTabLayoutを含む問題があります。 TabLayoutと各タブ内のデータは正常に動作しますが、まだmoveToState
エラーが表示されます(最初と最後の間を切り替えるとこのエラーが発生しません。私のアプリケーションはまだ正常にエラーで動作しますが、私はむしろ将来の合併症を避けるためにそれを取り除くでしょう。 (tabLayout付)Android - TabLayoutの中間タブエラー
LOGCAT
04-23 00:08:04.064 1598-1598/org.ramferno.scoutapplication.ramfernoscout W/FragmentManager: moveToState: Fragment state for TeamInfoTabOneFragment{1788a4f #9 id=0x7f0c00ca} not updated inline; expected state 3 found 2
04-23 00:12:56.007 1598-1598/org.ramferno.scoutapplication.ramfernoscout W/FragmentManager: moveToState: Fragment state for TeamInfoTabThreeFragment{29125dC#7 id=0x7f0c00ca} not updated inline; expected state 3 found 2
TeamInfoFragment.java
package org.ramferno.scoutapplication.ramfernoscout.fragments;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.ramferno.scoutapplication.ramfernoscout.adapters.InfoPagerAdapter;
import org.ramferno.scoutapplication.ramfernoscout.R;
/**
* A simple {@link Fragment} subclass.
*/
public class TeamInfoFragment extends Fragment {
TabLayout tabLayout;
ViewPager viewPager;
InfoPagerAdapter infoPagerAdapter;
public TeamInfoFragment() {
// Required empty public constructor
} //End of TeamInfoFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_team_info, container, false);
//Initializes variables
tabLayout = (TabLayout) view.findViewById(R.id.infoTabLayout);
viewPager = (ViewPager) view.findViewById(R.id.infoPager);
//Adds tabs to viewPager
infoPagerAdapter = new InfoPagerAdapter(getFragmentManager());
infoPagerAdapter.addFragments(new TeamInfoTabOneFragment(), "Team Info");
infoPagerAdapter.addFragments(new TeamInfoTabTwoFragment(), "Achievements");
infoPagerAdapter.addFragments(new TeamInfoTabThreeFragment(), "Past Tournaments");
//Sets adapter for viewPager then sets the same view pager for tabLayout
viewPager.setAdapter(infoPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
return view;
} //End of onCreateView
} //End of class
InfoPagerAdapter.java
package org.ramferno.scoutapplication.ramfernoscout.adapters;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import java.util.ArrayList;
public class InfoPagerAdapter extends FragmentStatePagerAdapter {
ArrayList<Fragment> fragments = new ArrayList<>();
ArrayList<String> tabTitles = new ArrayList<>();
public void addFragments(Fragment fragments, String titles) {
this.fragments.add(fragments);
this.tabTitles.add(titles);
} //End of addFragments
public InfoPagerAdapter(FragmentManager fm) {
super(fm);
} //End of InfoPagerAdapter
@Override
public Fragment getItem(int position) {
return fragments.get(position);
} //End of getItem
@Override
public int getCount() {
return fragments.size();
} //Edn of getCount
public CharSequence getPageTitle(int position) {
return tabTitles.get(position);
} //End of getPageTitle
} //End of class
もはや情報が必要な場合は私に連絡してください。
はまだ私も同じ問題を抱えています私の問題 –
への解決策を探して申し訳ありませんが、あなたがどんな解決策を見つける持って、このリンクは質問に答えるかもしれないが、 –