我已经尝试了一些方法片段 但是PlaceholderFragment不起作用
我设置了这个片段的片段
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_text, container, false);
ButterKnife.bind(this,view);
sectionsPagerAdapter = new SectionsPageAdapter(getContext(),((AppCompatActivity)getActivity()).getSupportFragmentManager());
viewPager = view.findViewById(R.id.view_pager);
viewPager.setAdapter(sectionsPagerAdapter);
tabs = view.findViewById(R.id.Texttabs);
tabs.setupWithViewPager(viewPager);
toolbar=view.findViewById(R.id.BlankTool);
PlaceholderFragment placeholderFragment=new PlaceholderFragment();
page=1;
s=Integer.toString(page);
Bundle bundle=new Bundle();
bundle.putInt("page",page);
placeholderFragment.setArguments(bundle);
这是目标PlaceholderFragment
public class PlaceholderFragment extends Fragment {
RecyclerView recyclerView;
WebView webView;
ArrayList<ItemData> itemDatas;
Myadapt myadapt;
String url;
public static Fragment newInstance(int i) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle bundle = new Bundle();
bundle.putInt("targetclass",i);
fragment.setArguments(bundle);
return fragment;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.filterblank,container,false);
int tarClass=getArguments().getInt("targetclass");
int TA=0;
String STA="";
int page=getArguments().getInt("page");
Log.v("data2",""+page);
int页面,我设置了logcat显示的任何值
V/data2: 0