3
I have a Mainactivity who owns 4 buttons, when the user selects some of them, the button method calls another Activity, which will display a query made in a XML in a Listview of this new Activity. I’m doing like this:
Method onCreate
of the new Activity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.refeicaoview);
lstDados = (ListView)findViewById(R.id.lstDados);
adpItens = new ArrayAdapter<String>(this, R.layout.item_lista);
lstDados.setAdapter(adpItens);
iniciaBusca(); //este método faz a consulta ao XML e retorna os dados para serem exibidos na listView acima
}
What I understand is that way, when you click the button on Mainactivity, it takes time to create the new Activity, because I imagine that iniciaBusca()
first, charge the listview and then display the screen.
What I want is for the screen to be created, and this method iniciaBusca()
start then, and while it runs, appear a progressDialog in the user interface.
Anyone have a tip? Solution? D
I got. ;)
Can use a
AsyncTask
in its "new" Activity and run this method within it and add your progressDialog!– Igor Mello