Hi all
Having a few issues getting a progress dialog to display correctly,
either the app crashes, or the spinner displays indefinitely.
I don't know if the code below helps at all, but what I would like to
do is have
the progress dialog display while the app is going through the For
loop, then stop when it has reached the end. I have tried countless
tutorials and have attempted different methods, all of which fail (as
in
the example below) any help would be appreciated, or just a point in
the right direction.
Thanks
Jon
public class Tester extends Activity
{
/** Called when the activity is first created. */
private Button OK;
private Button Cancel;
private Button Result;
private Button Exit;
private EditText EditTextExample;
public static TextView Label;
public static TextView Label2;
private CheckBox check;
public static int no1;
public static int no2;
public ProgressDialog myProgressDialog;
boolean isRunning = false;
Handler handler = new Handler(){
};
@Override
public void onCreate(Bundle new)
{
super.onCreate(new);
setContentView(R.layout.amap);
OK = (Button) findViewById(R.id.OK);
Cancel = (Button) findViewById(R.id.Cancel);
Result = (Button) findViewById(R.id.Result);
Exit = (Button) findViewById(R.id.Exit);
Label = (TextView) findViewById(R.id.Label);
Label2 = (TextView) findViewById(R.id.Label2);
EditTextExample = (EditText) findViewById
(R.id.EditTextExample);
check = (CheckBox) findViewById(R.id.check);
Cancel.setOnClickListener(CancelListener);
OK.setOnClickListener(OkListener);
Exit.setOnClickListener(ExitListener);
check.setOnClickListener(checkListener);
Result.setOnClickListener(ResultListener);
}
OnClickListener ExitListener = new OnClickListener()
{
public void onClick(View v)
{
finish();
}
};
OnClickListener ResultListener = new OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent();
intent.setClass(Tester.this, Results.class);
startActivity(intent);
}
};
OnClickListener CancelListener = new OnClickListener()
{
public void onClick(View v)
{
EditTextExample.setText("");
Label.setText("");
Label2.setText("");
cCheck.setChecked(false);
}
};
OnClickListener OkListener = new OnClickListener()
{
public void onClick(View v)
{
onStart();
Thread running = new Thread(new Runnable(){
public void run(){
text = EditTextExample.getText().toString();
if(text.length() == 0)
{
Label.setText("No Text!");
return;
}
else
{
try
{
for (int i = no1; i <= no2 ; i++)
{
try
{
// stuff happens here
Label.append("Text "
+ i + " Text " + text + "\n" );
}
finally
{
try
{
//other stuff here
}
catch () {}
}
handler.sendMessage(handler.obtainMessage
());
} //for
} //try
catch () {}
}
}
});
isRunning = true;
running.start();
}
};
public void onStop(){
super.onStop();
isRunning=false;
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---