How do I add a progressbar to my app?

Asked

Viewed 133 times

0

I have a Activity calling a method in the oncreate I created that’s called criarlista(). This method creates a ListView loading from an XML, and this process takes about 3.4 seconds because it is loading from an XML.

How do I rotate a simple progress bar during this time?

Someone could post an example, based on my model?

  • 1
  • That there was in webview, now I want before the call of a listview, I could not implement, I want to do with thread

  • Someone can help me?

  • 1

    Is this what you want? http://stackoverflow.com/a/7496195/1817673

  • 1

    @Warlock Consider posting an answer if you succeeded, and how you managed to solve your problem. Also because two comments offered you a help.

1 answer

0

I have a template in a webview

Mainacitivity

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebView myWebView = (WebView) findViewById(R.id.web_engine);

    myWebView.setWebViewClient(new MyBrowser());
    myWebView.clearCache(true);
    myWebView.clearHistory();

    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.getSettings().setLoadsImagesAutomatically(true);
    myWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    myWebView.loadUrl("http://www.mundodamulher.com.br/");
}

private class MyBrowser extends WebViewClient {
    @Override
    public void onPageFinished(WebView view, String url) {
        if (findViewById(R.id.splach_screen).getVisibility() == View.VISIBLE) {
            // show webview
            findViewById(R.id.main_view).setVisibility(View.VISIBLE);
            // hide splash screen
            findViewById(R.id.splach_screen).setVisibility(View.GONE);
        }
    }
}

}

activity_main

<?xml version="1.0" encoding="utf-8"?>

    <ProgressBar
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="160dp"
        android:layout_height="10dp"
        android:id="@+id/webViewProgress"
        android:indeterminateOnly="true"
        android:max="100"
        android:indeterminateTint="#e20400"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />


</RelativeLayout>
<LinearLayout
    android:id="@+id/main_view"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:visibility="invisible"
    >
    <WebView android:id="@+id/web_engine"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
</LinearLayout>

I know the color change of the bar works above api 21, yet to looking for lower api’s

Browser other questions tagged

You are not signed in. Login or sign up in order to post.