Contenido de ActivityMain se borra cuando se llama otro activity
Publicado por Ramon Humberto (3 intervenciones) el 04/02/2016 22:17:42
Hola buenas tardes/dias, tengo un detalle en mi App.
al iniciarse se conecta a un server y muestra unas imagenes y texto.
al seleccionar alguna imagen se llama otra activity y muestra la imagen mas grande.
al cerrar la activity y llamar la principal ya no se muestra el contenido que se habia descargado.
Agrego mi codigo por si es necesario:
Que estoy haciendo mal?
Saludos!
al iniciarse se conecta a un server y muestra unas imagenes y texto.
al seleccionar alguna imagen se llama otra activity y muestra la imagen mas grande.
al cerrar la activity y llamar la principal ya no se muestra el contenido que se habia descargado.
Agrego mi codigo por si es necesario:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.list);
adapter = new CustomListAdapter(this, movieList);
listView.setAdapter(adapter);
/*Evento Click ListView*/
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//***Muestra un Mensaje***
//Toast.makeText(MainActivity.this, "You Clicked at " +web[+ position], Toast.LENGTH_SHORT).show();
//***Abre otra pantalla y muestra la Imagen seleccionada.***
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
ImageView imgImagen = (ImageView) view.findViewById(R.id.thumbnail);
Bitmap imagen = ((BitmapDrawable) imgImagen.getDrawable()).getBitmap();
intent.putExtra("BitmapImage", imagen);
startActivity(intent);
}
});
/*Fin Evento Click listView*/
pDialog = new ProgressDialog(this);
// Showing progress dialog before making http request
pDialog.setMessage("Mostrando Imagenes...");
pDialog.show();
// changing action bar color
//getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#1b1b1b")));
if(cargada==false) {
// Adding request to request queue
AppController.getInstance().addToRequestQueue(movieReq);
cargada = true; //debes cambiar el valor de cargada=true y no te volvera a cargar las imagenes
}
}
protected void onResume() {
super.onResume();
cargada = true;
}
// Creating volley request obj
JsonArrayRequest movieReq = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
Movie movie = new Movie();
movie.setTitle(obj.getString("title"));
movie.setThumbnailUrl(obj.getString("image"));
movie.setRating(((Number) obj.get("rating"))
.doubleValue());
movie.setYear(obj.getInt("releaseYear"));
// Genre is json array
JSONArray genreArry = obj.getJSONArray("genre");
ArrayList<String> genre = new ArrayList<String>();
for (int j = 0; j < genreArry.length(); j++) {
genre.add((String) genreArry.get(j));
}
movie.setGenre(genre);
// adding movie to movies array
movieList.add(movie);
} catch (JSONException e) {
e.printStackTrace();
}
}
hidePDialog();
// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePDialog();
}
});
@Override
public void onDestroy() {
super.onDestroy();
hidePDialog();
}
private void hidePDialog() {
if (pDialog != null) {
pDialog.dismiss();
pDialog = null;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.main, menu);
return true;
}
AppController.getInstance().addToRequestQueue(movieReq) => Aqui es donde se manda llamar los datos al servidor.
Que estoy haciendo mal?
Saludos!
Valora esta pregunta


0