0
Yenho a ProgressBar
in my MainActivity
and would like to add a text like this "Carrying...". But I’m not getting it, someone could help me?
Below follows the code of my main activity.
package prosportacademia.prosportacademia;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Message;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.app.ProgressDialog;
import org.w3c.dom.Text;
public class MainActivity extends Activity {
//Faz a verificacao da conexao com a internet
//Fim da Verifica��o de conexao com a internet
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView wv = (WebView) findViewById(R.id.webView);
wv.setWebViewClient(new WebViewClient());
WebSettings ws= wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setSupportZoom(false);
//news implementation
ws.setSaveFormData(true);
wv.loadUrl("http://bbacpropaganda.com.br/websport/users");
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setLoadWithOverviewMode(true);
wv.setWebChromeClient(new WebChromeClient());
//Barra de Progresso / Carregando
final ProgressBar Pbar;
Pbar = (ProgressBar) findViewById(R.id.progressBar);
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if (progress < 100 && Pbar.getVisibility() == ProgressBar.GONE) {
Pbar.setVisibility(ProgressBar.VISIBLE);
}
Pbar.setProgress(progress);
if (progress == 100) {
Pbar.setVisibility(ProgressBar.GONE);
}
}
});
//Fim da Barra de Progresso / Carregando
}
//Fecha a Aplicacao Quando pressionar o botao voltar
@Override
public void onBackPressed(){
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
//Fecha a Aplicacao Quando pressionar o botao voltar
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Pbar.setMessage("Loading"); does not work?
– Geferson
Hello Geferson, Unfortunately it doesn’t work, has some other suggestion?
– Felipe Edwards Vanstocher
The progressbar appears on the screen, only you can not place any message, or it does not even appear?
– Geferson
It appears on the screen, only the circle spinning , but I want to add a text to make it more intuitive. : D
– Felipe Edwards Vanstocher
Yes yes, strange I use the property setMessage even to put message in it.
– Geferson
for me to use setMessage which package should I import? to thinking that should be it. How am I beginner in Dev. Android still get a lot rs.
– Felipe Edwards Vanstocher
Aah no, now that I’ve noticed, you’re using progressBar, really it doesn’t have this property(setMessage), I use the progressiDialog, pera ai que já posto um exemplo para você.
– Geferson