这是代码,如果用户单击按钮,当前会显示进度对话框,并且“环”没有旋转。但是如果我将 progreedialog 的代码粘贴到 onCreate 下,一旦加载屏幕,“环”就会旋转。帮我看看哪里出错了。。
StaffChoice 类:
public class StaffChoice extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.staffchoices);
}
public void onClickCategory(final View view)
{
final ProgressDialog progress=ProgressDialog.show(this, "Please wait", "Loading ...", true);
new Thread()
{
public void run()
{
Intent intent = new Intent(view.getContext(), Category.class);
startActivity(intent);
progress.dismiss();
}
}.start();
}
}
类别类中的 onCreate:
super.onCreate(savedInstanceState);
setContentView(R.layout.category);
final ListView lvCategory = (ListView) findViewById(R.id.lvCategory);
SoapObject Request = new SoapObject (NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
try
{
aht.call(SOAP_ACTION, soapEnvelope);
SoapObject resultString = (SoapObject) soapEnvelope.getResponse();
final String[] strCategory = new String[resultString.getPropertyCount()];
for(int i =0; i<resultString.getPropertyCount(); i++)
{
SoapObject array = (SoapObject) resultString .getProperty(i);
strCategory[i] = array.getProperty(0).toString(); //get category
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strCategory);
lvCategory.setAdapter(adapter);
lvCategory.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, final View arg1, int arg2, long arg3) {
Intent intent = new Intent(arg1.getContext(), CategoryGames.class);
startActivity(intent);
}
});
}
catch(Exception e)
{
String[] items = { "No Internet Connection, Please try again" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);
lvCategory.setAdapter(adapter);
}