I want to use TabActivity in my android app. each viewPager's pages contains 2 TextView and 1 ImageView. I want to write down my texts in ArrayString instead of simple String,but i don't know how to call it inTextView.setText?
my Fragment class:
public static class PlaceholderFragment extends Fragment {
private static final String ARG_SECTION_NUMBER = " " ;
public TextView label_TV, info_TV;
public ImageView photo_IMG;
public PlaceholderFragment() {
}
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_bio, container, false);
label_TV = (TextView) rootView.findViewById(R.id.section_label);
//label_TV.setText(?);
info_TV = (TextView) rootView.findViewById(R.id.section_info);
photo_IMG = (ImageView) rootView.findViewById(R.id.section_image);
return rootView;
}
}
FragmentPagerAdapter class:
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() {
return 6;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "SECTION 1";
..
}
return null;
}
}
string file:
<string-array name="titles">
<item>00</item>
<item>11</item>
</string-array>
how can i use titles arrayString for label_TV?
Probably, the best place to do so is via newInstance() method. If it is not dynamic of course :)