Note that there are some explanatory texts on larger screens.

plurals
  1. POProgress dialog on while starting a new activity
    primarykey
    data
    text
    <p>My app sets up a list of football team names, and on clicking a textview, the corresponding class is called in a the intent method.</p> <p>The classes that are called load an xml layout file which is approx 200kb. I would like to implement a progress/loading icon whilst the xml file loads in the background.</p> <p>I've looked on this site and read about ASynchTask but I don't know what code I need to write in the doInBackground() method.</p> <p>Here is my class:</p> <p>I have an array of textviews that get initialised, and an array of classnames assigned to each textview when clicked.</p> <p>Can anybody help me? I'm a noobie.</p> <p>As an alternative, is there a way of loading all these classes in the background when the user first clicks on the app?</p> <p>public class Transfers extends Activity {</p> <pre><code>public final int[] teams = { R.id.ars, R.id.ast, R.id.bir, R.id.bla, R.id.blp, R.id.bol, R.id.che, R.id.eve, R.id.ful, R.id.hul, R.id.lee, R.id.liv, R.id.mid, R.id.mnc, R.id.mnu, R.id.nor, R.id.nwu, R.id.por, R.id.qpr, R.id.sto, R.id.sun, R.id.swa, R.id.tot, R.id.wes, R.id.wig, R.id.wol }; public final String[] teamnames = { "ars", "ast", "bir", "bla", "blp", "bol", "che", "eve", "ful", "hul", "lee", "liv", "mid", "mnc", "mnu", "nor", "nwu", "por", "qpr", "sto", "sun", "swa", "tot", "wes", "wig", "wol" }; TextView tv; Class classname; String prefix = "ttj.android.ft.teams."; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.m_transfers); for (int i = 0; i &lt; teams.length; i++) { final int j = i; tv = (TextView) findViewById(teams[i]); tv.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { classname = Class.forName(prefix + teamnames[j]); Intent open = new Intent(Transfers.this, classname); startActivity(open); } catch (ClassNotFoundException e) { e.printStackTrace(); } } }); } ; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload