문제

This FragmentActivity creates a few fragments that are put in a slider (horizontal. Only one fragment is shown here):

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..

The Logger fragment creates its view inflating this 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>

For API 7, everything works (all fragments are loaded and the slider works) fine except that the TextView "numberOutput" does not scroll and can't be selected. For API 15, 16, 17 it wors fine. Any idea?

도움이 되었습니까?

해결책

Solved it by getting that TextView (numberOutput) at runtime and setting a movement method:

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

I did not find in the documentation that higher api levels automatically set any movement method.. so the why would be another question

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top