|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jun 2005
Città: Napoli
Messaggi: 1661
|
[Android] progress bar
ciao a tutti ! per l'applicazione che sto implementando mi piacerebbe mettere una progress bar tra una activity e un'altra. Mi aiutate ? in pratica seguendo un tutorial su internet sono arrivato ad implementare il seguente codice:
Codice:
public void onClick(View view) {
// get the increment value from the text box
EditText et = (EditText) findViewById(R.id.increment);
// convert the text value to a integer
increment = Integer.parseInt(et.getText().toString());
dialog = new ProgressDialog(this);
dialog.setCancelable(true);
dialog.setMessage("Caricamento...");
// set the progress to be horizontal
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
// reset the bar to the default value of 0
dialog.setProgress(0);
// get the maximum value
// EditText max = (EditText) findViewById(R.id.maximum);
// convert the text value to a integer
int maximum = 100;
// set the maximum value
dialog.setMax(maximum);
// display the progressbar
dialog.show();
// create a thread for updating the progress bar
Thread background = new Thread (new Runnable() {
public void run() {
// enter the code to be run while displaying the progressbar.
//
// This example is just going to increment the progress bar:
// So keep running until the progress value reaches maximum value
while (dialog.getProgress()< dialog.getMax()) {
// wait 500ms between each update
// active the update handler
progressHandler.sendMessage(progressHandler.obtainMessage());
}
if (dialog.getProgress() == dialog.getMax()){
Intent prima_intent=new Intent(getApplicationContext(),Prima.class);
startActivity(prima_intent);
overridePendingTransition(R.anim.fedeout, R.anim.fadein);
}
}
});
// start the background thread
background.start();
}
// handler for the background updating
Handler progressHandler = new Handler() {
public void handleMessage(Message msg) {
dialog.incrementProgressBy(increment);
}
__________________
|
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jun 2005
Città: Napoli
Messaggi: 1661
|
ho cambiato idea.. metto una rotellina di caricamento che gira solo quando il client (dispositivo) interoga il server... quindi la rotellina gira finquando l'operazione non va a buon fine
__________________
|
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Apr 2005
Messaggi: 5245
|
puoi postare il link del tutorial che stai seguendo ?
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Jun 2005
Città: Napoli
Messaggi: 1661
|
sicneramente l'ho perso ..perche poi ho cambiato totalmente il codice XD .. pero' ce ne sono tanti di tutorial
__________________
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 00:35.



















