带进度条的ListFragment(Api 10)我想要进度条Api16

时间:2014-02-03 23:26:24

标签: android progress-bar viewpagerindicator

我的问题是这个。我有两个listfragments两个TabPageIndicator(我正在使用库viewpagerindicator)。我正在覆盖OnCreateView,创建一个进度条和列表视图。我的问题是进度条是api级别10,我希望进度条是api级别16。 可能吗?如果是这样怎么样?

谢谢。

我的代码:

为main.xml分配了一个自定义主题(称为MyTheme),其主体为Theme.Light

main.xml

<com.viewpagerindicator.TabPageIndicator 
    android:id="@+id/indicator"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#FFFFFF"
     />


<android.support.v4.view.ViewPager 
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
/>

styles.xml

 <!-- CustomTabPageIndicator -->

<style name="Theme.MyTheme" parent="@android:style/Theme.Light">
    <item name="vpiTabPageIndicatorStyle">@style/MyTabPageIndicator</item>

</style>

<style name="MyTabPageIndicator" parent="Widget.TabPageIndicator">
    <item name="android:textSize">14sp</item> 
    <item name="android:textColor">#000000</item>    
   <item name="android:background">@drawable/custom_tab_indicator</item>   
 <!--    -->
</style>

编码listfragments之一

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //return super.onCreateView(inflater, container, savedInstanceState);
        final Context context = getActivity();
        FrameLayout root = new FrameLayout(context);

        LinearLayout pframe = new LinearLayout(context);
        pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
        pframe.setOrientation(LinearLayout.VERTICAL);
        pframe.setVisibility(View.GONE);
        pframe.setGravity(Gravity.CENTER);

      ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);         
       progress.setBackground(getResources().getDrawable(R.drawable.custombarprogress));

        pframe.addView(progress, new FrameLayout.LayoutParams(
               ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        //pframe.addView(progress, new FrameLayout.LayoutParams(50,50));
        root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

        FrameLayout lframe = new FrameLayout(context);
        lframe.setId(INTERNAL_LIST_CONTAINER_ID);

       TextView tv = new TextView(getActivity());
        tv.setId(INTERNAL_EMPTY_ID);
        tv.setGravity(Gravity.CENTER);
        lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

        ListView lv = new ListView(getActivity());
        lv.setId(android.R.id.list);
        lv.setDrawSelectorOnTop(false);
        lframe.addView(lv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

        root.addView(lframe, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

        root.setLayoutParams(new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

        return root;
}

0 个答案:

没有答案