Curso-Android-Desarrollo-de-Aplicaciones-Móviles
Curso-Android-Desarrollo-de-Aplicaciones-Móviles
Curso-Android-Desarrollo-de-Aplicaciones-Móviles
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CURSO ANDROID<br />
38<br />
startActivity(backToMainActivity);<br />
Al finalizar, el código <strong>de</strong> esta clase es el siguiente:<br />
package com.android.mdw.<strong>de</strong>mo;<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.widget.TextView;<br />
public class ShowElement extends Activity {<br />
@Overri<strong>de</strong><br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.showelement);<br />
Intent it = getIntent();<br />
int position = it.getIntExtra(Main.POSITION_KEY, -1);<br />
if (position != -1) {<br />
MyApp appState = ((MyApp)getApplication());<br />
Element e = appState.getData().get(position);<br />
TextView txtTitle = (TextView)findViewById(R.id.txtTitle);<br />
txtTitle.setText(e.getTitle());<br />
TextView txtAuthor = (TextView)findViewById(R.id.txtAuthor);<br />
txtAuthor.setText(“por “ + e.getAuthor());<br />
TextView txtDesc = (TextView)findViewById(R.id.txtDesc);<br />
txtDesc.setText(e.getDescription());<br />
} else {<br />
Intent backToMainActivity = new Intent(this, Main.class);<br />
backToMainActivity.putExtra(Main.POSITION_KEY, -1);<br />
startActivity(backToMainActivity);<br />
}<br />
}<br />
}<br />
Esas son las clases adicionales luego el trabajo es sobre la Activity principal: la clase Main.java