I am doing an exercise in which I entered Fahrenheit degrees and I convert them to Celsius. On the second screen the result appears, but I want to put a textView
that says "The result is" and I do not get it. Do I need to create another xml file or do I also need to pass as a parameter as well as pass the value that I got in the formula?
/* CODIGO JAVA DEL SEGUNDO ACTIVITY */
public class SecondActivity extends ActionBarActivity {
TextView resultado;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
resultado= (TextView) findViewById(R.id.resultado);// Acá esta el texto
//que dice el
//resultado es, pero
//no aparece :/
String valor=getIntent().getExtras().getString("clave");
((TextView)findViewById(R.id.resultado)).setText(valor);
}
}
XML OF THE 2ND ACTIVITY:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.brenda.celsius_a_farenheit.SecondActivity">
<TextView
android:id="@+id/resultado"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/resultado" />
</LinearLayout>
STRING XML
<resources>
<string name="app_name"></string>
<string name="Etiqueta_datos">Ingrese temperatura</string>
<string name="Boton">Click para ver el resultado</string>
<string name="resultado">El resultado es: </string>
</resources>