ViewPager:アダプタが接続されていません。レイアウトをスキップ; AndroidRuntime:java.lang.IllegalStateException:executePendingTransactions
への再帰エントリ.... MoviesDetailsViewPagerAdapterは、カスタムアダプタ.........
package com.example.beetel.moviesApp.adapter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.example.beetel.moviesApp.DetailsFragmentActivity;
import com.example.beetel.moviesApp.ReviewsFragment;
import com.example.beetel.moviesApp.TrailerFragment;
import com.example.beetel.moviesApp.data.model.MovieResultListModel;
import com.example.beetel.moviesApp.utilities.MovieAPIUtility;
/**
* Created by beetel on 7/03/2016.
*/
public class MoviesDetailsViewPagerAdapter extends FragmentStatePagerAdapter {
private MovieResultListModel.ResultModel resultModel;
public MoviesDetailsViewPagerAdapter(FragmentManager fm,MovieResultListModel.ResultModel model)
{
super(fm);
this.resultModel=model;
}
@Override
public int getCount() {
return MovieAPIUtility.TABS_MOVIE_DETAIL.length;
}
@Override
public int getItemPosition(Object object)
{
return POSITION_NONE;
}
@Override
public Fragment getItem(int pos)
{
switch (pos)
{
case 0:
DetailsFragmentActivity detailsFragmentActivity=new DetailsFragmentActivity();
Bundle arg=new Bundle();
arg.putParcelable(MovieAPIUtility.EXTRA_DETAIL_FRAGMENT, resultModel);
detailsFragmentActivity.setArguments(arg);
return detailsFragmentActivity;
case 1:
TrailerFragment trailerFragment=new TrailerFragment();
Bundle bundle=new Bundle();
bundle.putParcelable(MovieAPIUtility.EXTRA_TRAILER_FRAGMENT, resultModel);
trailerFragment.setArguments(bundle);
return trailerFragment;
case 2:
ReviewsFragment reviewsFragment=new ReviewsFragment();
Bundle args=new Bundle();
args.putParcelable(MovieAPIUtility.EXTRA_REVIEW_FRAGMENT, resultModel);
reviewsFragment.setArguments(args);
return reviewsFragment;
default:
return new Fragment();
}
}
@Override
public CharSequence getPageTitle(int position){
if (position>=0&& position<MovieAPIUtility.TABS_MOVIE_DETAIL.length)
{
return MovieAPIUtility.TABS_MOVIE_DETAIL[position];
}
return null;
}
}
です... ..... DetailsFragmentActivityコード..........このissue..Pleaseは私がこれを理解するのに役立ち直面
package com.example.beetel.moviesApp;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.example.beetel.moviesApp.adapter.MoviesDetailsViewPagerAdapter;
import com.example.beetel.moviesApp.data.model.MovieResultListModel;
import com.example.beetel.moviesApp.utilities.MovieAPIUtility;
import butterknife.ButterKnife;
/**
* Created by beetel on 4/03/2016.
*/
public class DetailsFragmentActivity extends Fragment {
ImageView imgPoster;
private MovieResultListModel.ResultModel model;
private ViewPager viewPager;
private TabLayout tabLayout;
private boolean fromactivity=true;
private boolean twoPane=false;
public DetailsFragmentActivity(){}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Toolbar toolbar2 = (Toolbar) getActivity().findViewById(R.id.toolbar_movie_detail);
imgPoster = (ImageView) getActivity().findViewById(R.id.toolbar_image_backdrop);
if (getActivity().findViewById(R.id.multipan) != null) {
twoPane = true;
toolbar2.setTitle(model.getOriginalTitle());
}
if (!twoPane)
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(model.getOriginalTitle());
try {
setViewpagerAndBackDrop();
} catch (NullPointerException e) {
e.printStackTrace();
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState)
{
View view=inflater.inflate(R.layout.movie_fragment_main,container,false);
ButterKnife.bind(this,view);
model=getActivity().getIntent().getParcelableExtra(MovieAPIUtility.EXTRA_RESULT_MODEL);
if(model==null){
model=this.getArguments().getParcelable(MovieAPIUtility.EXTRA_RESULT_MODEL);
fromactivity=false;
}
return view;
}
private void setViewpagerAndBackDrop()
{
viewPager=(ViewPager)getActivity().findViewById(R.id.vp_movie_detail);
tabLayout=(TabLayout)getActivity().findViewById(R.id.tabs);
//FragmentManager fragmentManager=this.getFragmentManager();
MoviesDetailsViewPagerAdapter pagerAdapter=new MoviesDetailsViewPagerAdapter(getActivity().getSupportFragmentManager(),model);
pagerAdapter.notifyDataSetChanged();
viewPager.setAdapter(pagerAdapter);
tabLayout.setupWithViewPager(viewPager);
Glide.with(DetailsFragmentActivity.this)
.load(MovieAPIUtility.URL_IMAGE_BACKDROP_BASE+model.getBackdropUrl())
.error(R.drawable.poster)
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imgPoster);
}
}
。 この投稿に記載されている解決策を試しました。 ViewPager: Recursive entry to executePendingTransactionsViewPager: Recursive entry to executePendingTransactions
コールを削除しますto notifyDataSetChanged() –
@DanielNugentアダプタがデータ変更についてどのように知るのですか? – PN10
@DanielNugent kkk ..私はv4を使用しています:23.2.0サポートライブラリ..何ができますか? – PN10