这个FragmentActivity会创建一些放在滑块中的片段(水平。这里只显示一个片段):
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..
Logger片段创建其视图,膨胀此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>
对于API 7,除了TextView“numberOutput”不滚动且无法选择外,一切正常(所有片段都已加载且滑块正常工作)很好。对于API 15,16,17,它很好。有什么想法吗?
答案 0 :(得分:0)
通过在运行时获取TextView(numberOutput)并设置移动方法来解决它:
rootView = (ViewGroup) inflater.inflate(R.layout.dicelogger_lo, container, false);
mLoggerBody = (TextView)rootView.findViewById(R.id.numberOutput);
mLoggerBody.setMovementMethod(new ScrollingMovementMethod());
我没有在文档中发现更高的api级别自动设置任何移动方法..所以为什么会是另一个问题