2013-04-09 7 views
0

Cette FragmentActivity crée quelques fragments qui sont mis dans un curseur (horizontal Un seul fragment est montré ici.):TextView dans PagerAdapter: scrollable à API15-17, pas API7

public class MainActivity2 extends FragmentActivity{ 

    private ViewPager mPager; 
    private FragmentStatePagerAdapter mPagerAdapter; 
    private Logger mLogger; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main_container); 

     mLogger = new Logger(); 
     mPager = (ViewPager)findViewById(R.id.pager); 
     mPagerAdapter = new SliderAdapter(getSupportFragmentManager()); 
     mPager.setAdapter(mPagerAdapter); 

    ... //goes on with activity, the adapter is set correctly.. 

Le fragment Logger crée son point de vue gonfler ce xml:

<TextView 
     android:id="@+id/LoggerLoTitle" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:ems="10" 
     android:layout_weight="2" 
     android:gravity="center" 
     android:textStyle="bold" 
     android:textColor="#000033" 
     android:textSize="16sp" 
     android:text="@string/logger" 
     android:layout_marginTop="30sp" />  
    <TextView 
     android:id="@+id/numberOutput" 
     android:textIsSelectable="true" 
     android:layout_width="0dp" 
     android:layout_weight="13" 
     android:layout_height="fill_parent" 
     android:gravity="top" 
     android:freezesText="true" 
     android:maxLines = "50" 
     android:layout_marginLeft="22dp" 
     android:scrollbars = "vertical" 
     android:layout_marginTop="45sp"/> 
    <Button 
     android:background="#80FFFFFF" 
     android:gravity="center" 
     android:layout_width="0dp" 
     android:layout_weight="2" 
     android:layout_height="fill_parent" 
     android:freezesText="true" 
     android:scrollbars = "vertical" 
     android:layout_marginTop="45sp" 
     android:textColor="#000000" 
     android:textStyle="bold" 
     android:text="@string/logger_ad" 
     android:onClick="whatsNew"/> 
</LinearLayout> 

Pour API 7, tout fonctionne (tous les fragments sont chargés et les travaux de curseur) bien, sauf que le TextView "numberOutput" ne défile et ne peut pas être sélectionné. Pour API 15, 16, 17 ça va bien. Une idée?

Répondre

0

a résolu le problème en obtenant que TextView (numberOutput) lors de l'exécution et la mise en une méthode de mouvement:

rootView = (ViewGroup) inflater.inflate(R.layout.dicelogger_lo, container, false); 
mLoggerBody = (TextView)rootView.findViewById(R.id.numberOutput); 
mLoggerBody.setMovementMethod(new ScrollingMovementMethod()); 

Je ne trouve pas dans la documentation que les niveaux de api plus automatiquement mis toute méthode de mouvement .. donc la RAISONS être une autre question