android嵌入式进度条在布局中不显示片段

时间:2014-04-27 00:54:23

标签: android gridview android-progressbar

嘿我想在Gridview加载项目之前显示嵌入在布局中的进度条。目前进度条根本不显示,甚至没有抛出异常请帮我弄清楚为什么它不出现在这里是我的xml代码它现在给我一个错误后做了一些改变这里是它目前看起来如何以及它给出的错误

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<GridView
    android:id="@+id/gridView_news"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:numColumns="1"
    android:background="@drawable/border"
     >  
</GridView>
 <ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
 />
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#F0F0F0"
    android:layout_alignParentBottom="true"
    android:gravity="center_horizontal"
    android:orientation="horizontal"
    android:paddingTop="5dp" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginRight="10dp"
        android:scaleType="fitXY"
        android:src="@drawable/twitter" />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:scaleType="fitXY"
        android:src="@drawable/facebook" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginLeft="10dp"
        android:scaleType="fitXY"
        android:src="@drawable/youtube" />
</LinearLayout>
</RelativeLayout>

这是我的片段代码

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.home2, container, false);

    int i = getArguments().getInt(ARG_MENU_NUMBER);
    String titleString = getResources().getStringArray(R.array.drawer_menu)[i];
    getActivity().setTitle(titleString);
    gridNews = (GridView) rootView.findViewById(R.id.gridView_news);
    mProgresBar = (ProgressBar)rootView.findViewById(R.id.progressBar);
    mArrayName = new ArrayList<String>();
    mArrayDescription = new ArrayList<String>();
    mArrayImage = new ArrayList<String>();

    /*final TextView tv = (TextView) rootView.findViewById(R.id.textView_des);
    tv.setText(Html.fromHtml(getString(R.string.jkia_description)));

    final TextView tv3 = (TextView) rootView.findViewById(R.id.textView3);
    tv3.setText(Html.fromHtml(getString(R.string.secu)));

    final TextView tv46 = (TextView) rootView.findViewById(R.id.textView46);
    tv46.setText(Html.fromHtml(getString(R.string.launch)));*/

    //tv.setLinksClickable(true);
    //tv.setAutoLinkMask(Linkify.ALL);

    ImageView tweet = (ImageView) rootView.findViewById(R.id.imageView2);
    ImageView you = (ImageView) rootView.findViewById(R.id.imageView3);
    ImageView fb = (ImageView) rootView.findViewById(R.id.imageView4);

    tweet.setOnClickListener(this);
    you.setOnClickListener(this);
    fb.setOnClickListener(this);

    if(result2 != null){
        processJson(result2);

    }else{
    if (NetworkConnectionStatus.isOnline(getActivity())) {
        //new GetCurrenciesTask().execute();
        runStringLoader3();
        }
    }



    return rootView;
}

抛出的错误是

04-27 00:56:45.394: E/AndroidRuntime(1162): FATAL EXCEPTION: main
04-27 00:56:45.394: E/AndroidRuntime(1162): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shimbamobile.android.kaa/com.shimbamobile.android.kaa.MainMenu}: java.lang.ClassCastException: android.widget.GridView cannot be cast to android.widget.ProgressBar
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.os.Looper.loop(Looper.java:137)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.ActivityThread.main(ActivityThread.java:5041)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at java.lang.reflect.Method.invoke(Method.java:511)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at dalvik.system.NativeStart.main(Native Method)
04-27 00:56:45.394: E/AndroidRuntime(1162): Caused by: java.lang.ClassCastException: android.widget.GridView cannot be cast to android.widget.ProgressBar
04-27 00:56:45.394: E/AndroidRuntime(1162):     at com.shimbamobile.android.kaa.fragments.HomeFragment.onCreateView(HomeFragment.java:74)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.Activity.performStart(Activity.java:5114)
04-27 00:56:45.394: E/AndroidRuntime(1162):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
04-27 00:56:45.394: E/AndroidRuntime(1162):     ... 11 more

任何帮助将不胜感激

0 个答案:

没有答案