TabLayout
에 현재 fragment
의 콘텐츠를 어떻게 동적으로 변경할 수 있습니까? 예를 들어, 현재 조각에 목록이 있고 목록이 변경된 경우 조각 레이아웃을 업데이트하는 방법은 무엇입니까?TabLayout에서 현재 조각의 데이터를 변경하는 방법은 무엇입니까?
여기에 기본이
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
int areaID = getArguments().getInt(ARG_SECTION_NUMBER);
textView.setText(getString(R.string.section_format, areaID));
return rootView;
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "SECTION 1";
case 1:
return "SECTION 2";
case 2:
return "SECTION 3";
}
return null;
}
}
당신은 당신이 뭘 하려는지에 좀 더 구체적으로 수를 호출? – Mauker
@Mauker ArrayList 및 ListView가 있고 ArrayList가 변경되면 변경된 ArrayList를 현재 조각에 표시하려고합니다. –