好的,我有一个Activity,我有viewpager和textview。然后我有扩展FragmentStatePagerAdapter的适配器,这是它的代码:
categories_vs_groups(categories_id)
最后我有片段:
public AdapterCustomPage(FragmentManager fm, Context context, TextView TV ) {
super(fm);
mContext = context;
mTV = TV;
}
@Override
public Fragment getItem(int position) {
// Create fragment object
Fragment fragment = new ImageFragmentKatalozi();
Bundle args = new Bundle();
Log.i("Poizicija" , String.valueOf(position));
String url = Static.katalozi.getSlikeKataloga().get(position);
args.putString("url", url);
fragment.setArguments(args);
mTV.setText(String.valueOf(position + 1) + "/" + String.valueOf(maxBrojStrana));
String link = Static.katalozi.getUrl();
args.putString("linkKataloga", link);
if(position == 0){
Message.message(mContext, "Na prvoj stranici kataloga ste");
}
if(position == getCount() - 1){
Message.message(mContext, "Na poslednjoj stranici kataloga ste");
}
return fragment;
}
@Override
public int getItemPosition(Object object) {
pozicija = super.getItemPosition(object);
return super.getItemPosition(object);
}
@Override
public int getCount() {
return maxBrojStrana;
}
现在,问题是,我在主要活动中的TextView并没有让我回到片段的正确位置。它提供了良好的getCount位置,但是当我向右滑动时它变为+ 1,当我向左滑动时,它变为0.当我将整个textView代码和xml放在片段部分时,它运行良好,但是然后它用片段滑动。有什么帮助吗?
答案 0 :(得分:0)
html body {
position: absolute;
height: 100%;
width: 100% !important;
margin: 0 auto;
text-align:center;
}
@media all and (min-width: 200px) and (max-width: 850px) {
html body {
position: absolute;
height: 100%;
width: 100% !important;
margin: 0 auto;
text-align:center;
}
}