dejar de recargar ListView en cambio de orientación en android

Tengo un ListView, populated from a XML. Everything is working fine, but when i change my device's orientation(Portrait<-->Landscape) it reloads the ListView. I want to stop it. I have used onSaveInstanceState y onConfigurationChanged. But it still reloads.

Aquí está mi código:

protected void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        alrowDataView = savedInstanceState.getParcelableArrayList("name");
    //  Toast.makeText(MainActivity.this,alrowDataView.size() , Toast.LENGTH_LONG).show();

        // lvrowDataView=(ListView) findViewById(;
        Toast.makeText(MainActivity.this,"NOdata" , Toast.LENGTH_LONG).show();

    lvrowDataView = (ListView) findViewById(;
    ParsingXml parsing = new ParsingXml();

After that general ListView operations...

y aquí está el código para OnSavedInstanceState y onConfigurationChanged.

public void onConfigurationChanged(Configuration newConfig) {

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(MainActivity.this, "landscape", Toast.LENGTH_SHORT).show();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        Toast.makeText(MainActivity.this, "portrait", Toast.LENGTH_SHORT).show();

protected void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putParcelableArrayList("name", alrowDataView);
    //Toast.makeText(MainActivity.this, alrowDataView.size(),Toast.LENGTH_LONG).show();

and these are the declarations

    private ListView lvrowDataView;
private ArrayList<RowData> alrowDataView;
RowDataAdapter adapterRowData;

No quiero usar android:configChanges="orientation"

También en onSaveInstanceState the ArrayListis null!!!

preguntado el 25 de septiembre de 13 a las 10:09

So, what is your reason for not wanting to use configChanges en tu manifiesto? -

well firstly it is not working,i have tried it!then it is just a demo!in the real one,there will be some other activity which i need to be refreshed.Thats why.I didn't knew that before. -

1 Respuestas

Prueba de esta manera


Is not working with latest android api 3.0+

You need to use like this


Respondido el 25 de Septiembre de 13 a las 10:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.