Не могу понять в чем проблема ошибки
java.lang.IllegalStateException:
at android.support.v4.app.FragmentManagerImpl.checkStateLoss (FragmentManager.java:1842)
at android.support.v4.app.FragmentManagerImpl.enqueueAction (FragmentManager.java:1860)
at android.support.v4.app.BackStackRecord.commitInternal (BackStackRecord.java:650)
at android.support.v4.app.BackStackRecord.commit (BackStackRecord.java:609)
at com.robin.vitalij.tanksapi.Retrofit.fragment_adapter.Fragment_adapter_cvodka$SectionsPagerAdapter.getItem (Fragment_adapter_cvodka.java:244)
at android.support.v4.app.FragmentPagerAdapter.instantiateItem (FragmentPagerAdapter.java:101)
at android.support.v4.view.ViewPager.addNewItem (ViewPager.java:1034)
at android.support.v4.view.ViewPager.populate (ViewPager.java:1248)
at android.support.v4.view.ViewPager.populate (ViewPager.java:1116)
at android.support.v4.view.ViewPager$3.run (ViewPager.java:273)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:803)
at android.view.Choreographer.doCallbacks (Choreographer.java:603)
at android.view.Choreographer.doFrame (Choreographer.java:572)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:789)
at android.os.Handler.handleCallback (Handler.java:733)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:157)
at android.app.ActivityThread.main (ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1081)
at dalvik.system.NativeStart.main (Native Method)
Ссылается на строку fragmentTransaction7.commit();
Fragment_ranked_battles fragment_ranked_battles = new Fragment_ranked_battles();
FragmentTransaction fragmentTransaction7;
fragmentTransaction7 = getActivity().getSupportFragmentManager().beginTransaction();
Bundle bundle7 = new Bundle();
if(vibor == true)
bundle7.putInt("Player", 1);
else
bundle7.putInt("Player", 2);
fragment_ranked_battles.setArguments(bundle7);
fragmentTransaction7.commit();
return fragment_ranked_battles;
сам фрагмент
public class Fragment_adapter_cvodka extends Fragment {
private ViewPager mViewPager;
private TabLayout tabLayout;
private String[] adapter_cvodka_dost;
private SectionsPagerAdapter mSectionsPagerAdapter;
private Player player;
private boolean vibor;
private AdView mAdView;
private SharedPreferences sPref;
public static final String APP_PREFERENCES = "mysettings";
public static final String APP_PREFERENCES_DATE = "DATE";
private boolean isVibor;
private Date date_time;
private Date date;
//Рекламный блок
private InterstitialAd mInterstitialAd;
@Override
public void onResume() {
super.onResume();
mSectionsPagerAdapter.notifyDataSetChanged();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_adapter_cvodka, container, false);
sPref = getActivity().getSharedPreferences(
APP_PREFERENCES, getActivity().MODE_PRIVATE);
SharedPreferences.Editor ed = sPref.edit();
sPref = getActivity().getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
long OBNOVLENIE = sPref.getLong(APP_PREFERENCES_DATE, 0);
date_time = new Date();
date = date_time;
MobileAds.initialize(getActivity().getApplicationContext(),
getResources().getString(R.string.admod_id));
mAdView = (AdView) view.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
if (!InternetConnection.isOnline(getActivity()) || OBNOVLENIE > date.getTime()) {
mAdView.setVisibility(View.GONE);
isVibor = false;
}
else {
// Initialize the Mobile Ads SDK.
MobileAds.initialize(getActivity(), getResources().getString(R.string.admod_id));
// Create the InterstitialAd_ad and set the adUnitId.
mInterstitialAd = new InterstitialAd(getActivity());
// Defined in res/values/strings.xml
mInterstitialAd.setAdUnitId(getResources().getString(R.string.admod_itteractive));
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
InterstitialAd_ad.startGame(mInterstitialAd);
}
});
InterstitialAd_ad.startGame(mInterstitialAd);
isVibor = true;
mAdView.setVisibility(View.VISIBLE);
}
adapter_cvodka_dost = getResources().getStringArray(R.array.adapter_cvodka_dost);
Bundle bundle = getArguments();
if (bundle != null) {
vibor = bundle.getBoolean("Player_clan");
if(vibor == true)
player = ((LocationTanki) getActivity().getApplication()).getPlayer2();
else
{
player = ((LocationTanki) getActivity().getApplication()).getPlayer_find();
}
}
else
player = null;
mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
mViewPager = (ViewPager) view.findViewById(R.id.vpPager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
if(isVibor == true) { //реклама
Date date = new Date();
if(date_time.getTime() <= date.getTime() ) {
InterstitialAd_ad.showInterstitial(mInterstitialAd);
Calendar instance = Calendar.getInstance();
instance.setTime(date);
instance.add(Calendar.MINUTE, 5);// прибавляем 1 к установленной дате
date_time = instance.getTime(); // получаем измененную дату
}
}
}
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
if(player.getChet() == 1)
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(player.getPersonaly_dannie().getNickname());
else
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(getResources().getString(R.string.Cvodka));
tabLayout = (TabLayout) view.findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
tabLayout.setSelected(true);
return view;
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public int getItemPosition (Object object) { return POSITION_NONE; }
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
Fragment_cvodka fragment_cvodka = new Fragment_cvodka();
FragmentTransaction fragmentTransaction;
fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
Bundle bundle = new Bundle();
Log.e("TETETETETET", Boolean.toString(vibor));
bundle.putBoolean("Player", vibor);
fragment_cvodka.setArguments(bundle);
fragmentTransaction.commit();
return fragment_cvodka;
case 1:
Fragment_statistika fragment_statistika = new Fragment_statistika();
FragmentTransaction fragmentTransaction3;
fragmentTransaction3 = getActivity().getSupportFragmentManager().beginTransaction();
Bundle bundle3 = new Bundle();
if(vibor == true)
bundle3.putInt("Player", 1);
else
bundle3.putInt("Player", 2);
fragment_statistika.setArguments(bundle3);
fragmentTransaction3.commit();
return fragment_statistika;
case 2:
Fragment_ranked_battles fragment_ranked_battles = new Fragment_ranked_battles();
FragmentTransaction fragmentTransaction7;
fragmentTransaction7 = getActivity().getSupportFragmentManager().beginTransaction();
Bundle bundle7 = new Bundle();
if(vibor == true)
bundle7.putInt("Player", 1);
else
bundle7.putInt("Player", 2);
fragment_ranked_battles.setArguments(bundle7);
fragmentTransaction7.commit();
return fragment_ranked_battles;
case 3:
Fragment_texnika fragment_texnika = new Fragment_texnika();
FragmentTransaction fragmentTransaction4;
fragmentTransaction4 = getActivity().getSupportFragmentManager().beginTransaction();
Bundle bundle4= new Bundle();
bundle4.putBoolean("Player", vibor);
fragment_texnika.setArguments(bundle4);
fragmentTransaction4.commit();
return fragment_texnika;
case 4:
Fragment_dostizenie fragment_dostizenie = new Fragment_dostizenie();
FragmentTransaction fragmentTransaction2;
fragmentTransaction2 = getActivity().getSupportFragmentManager().beginTransaction();
Bundle bundle2 = new Bundle();
bundle2.putBoolean("Player", vibor);
bundle2.putBoolean("Result", false);
fragment_dostizenie.setArguments(bundle2);
fragmentTransaction2.commit();
return fragment_dostizenie;
case 5:
Fragment_infografika fragment_infografika = new Fragment_infografika();
FragmentTransaction fragmentTransaction6;
fragmentTransaction6 = getActivity().getSupportFragmentManager().beginTransaction();
Bundle bundle6= new Bundle();
bundle6.putBoolean("Player", vibor);
// bundle6.putString("Player", playes_String);
fragment_infografika.setArguments(bundle6);
fragmentTransaction6.commit();
return fragment_infografika;
default:
return null;
}
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return adapter_cvodka_dost[0];
case 1:
return adapter_cvodka_dost[1];
case 2:
return adapter_cvodka_dost[2];
case 3:
return adapter_cvodka_dost[3];
case 4:
return adapter_cvodka_dost[4];
case 5:
return adapter_cvodka_dost[5];
}
return null;
}
@Override
public int getCount() {
// Show 3 total pages.
return 6;
}
}
}
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Перевод документов на английский язык: Важность и ключевые аспекты
Какие существуют виды рекламных бордов и как выбрать подходящий?
Как я уже понял, спиннер обновить легко и просто не получитсяУ меня при включении в него загружается вот этот пустой List
У меня задача настороить logbackxml так, чтобы каждый день создавался новый файл log_%d{yyyy-MM-dd}
В applicationproperties добавлены поля
ЗдравствуйтеСегодня столкнулся с такой проблемой: В android studio, в дизайнере приложение выглядит нормально, кнопки отдельны друг от друга, но При...