M0286_Libro Curso

4: Web móvil en acción

public class Start extends Activity { private TextView txtTime;

/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout. main );

txtTime = (TextView) findViewById(R.id. txtTime ); // añadimos el manejador del evento click del botón final Button btnCallWebService = (Button)

findViewById(R.id. btnCallWebService );

btnCallWebService.setOnClickListener(new

OnClickListener() {

public void onClick(View v) {

CallWebServiceTask task = new

CallWebServiceTask();

task.applicationContext = Start.this; task.execute();

}

});

} Creamos la clase CallWebServiceTask que extiende de AsyncTask y sobrescribimos sus métodos. public class CallWebServiceTask extends AsyncTask { private ProgressDialog dialog; protected Context applicationContext; @Override protected void onPreExecute() { this.dialog = ProgressDialog. show (applicationContext, “Calling”, “Time Service...”, true);

233

Made with FlippingBook - Online catalogs