Sto leggendo dati xml da un URL. Ha funzionato bene quando era in modalità verticale. Ma volevo cambiarlo in modalità orizzontale. Ma ottiene l'eccezione android.view.WindowLeaked.android.view.WindowLeaked exception
Per favore aiutatemi. Grazie in anticipo. Questo è il mio codice
package com.eisuru.abc;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.pm.ActivityInfo;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView tvResponse;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
tvResponse = (TextView) findViewById(R.id.tvResponse);
new PostAsync().execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
class PostAsync extends AsyncTask<Void, Void, Void> {
ProgressDialog pd; XMLHelper helper;
@Override
protected void onPreExecute() {
pd = ProgressDialog.show(MainActivity.this, "Exchange Rates", "Loading Exchange rates values ...", true, false);
}
@Override
protected Void doInBackground(Void... arg0) {
helper = new XMLHelper(); helper.get();
return null;
}
@Override
protected void onPostExecute(Void result)
{
StringBuilder builder = new StringBuilder();
for(Exrate_values post : helper.exrates) {
builder.append("\n\t " + post.getDate());
builder.append("\t \t\t " + post.getFrom_currency());
builder.append("\t \t\t " + post.getTo_Currency());
builder.append("\t \t\t " + post.getExrt_buy());
builder.append("\t \t\t\t " + post.getExrt_sell());
builder.append("\n");
}
tvResponse.setText(builder.toString());
pd.dismiss();
}
}
}
Grazie mille per il tuo utile commento. Ho fatto il secondo metodo. Ha funzionato molto bene. 'android: screenOrientation =" landscape "' 'android: configChanges =" tastiera | keyboardHidden | orientation | screenLayout | uiMode | screenSize | smallestScreenSize ">' – Isuru
@Isuru Felice di aiutare, divertiti a programmare. –
Il metodo 1 ha funzionato perfettamente per me. Nota interessante: avevo già dichiarato l'orientamento nelle configChanges nel mio manifest quando stavo ottenendo la fuga della finestra in origine. – LargeGlasses