这个 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,它运行良好。任何的想法?