I'm new to android I'm trying to get the student details from sample form to display them in next screen, but it's throwing an error which I mentioned in above title. So, first I'm creating sample form for entering student details through main activity and including it's xml file, after entering the details and pressing submit button in the next screen it should print the above details name --(name which entered in sample form) age -- age " gender -- gender " education --edu " But it's not printing the details.
My displayActivity.java code is:
package first.sample.com.task1;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TextView;
public class DisplayActivity extends Activity {
private TableLayout tableLayout;
private int student_display_age;
private int student_display_name;
private int student_display_gender;
private int student_display_edu;
@Override
protected void onCreate(Bundle savedInstanecState) {
super.onCreate(savedInstanecState);
setContentView(R.layout.display_activity);
Bundle b = getIntent().getExtras();
tableLayout=(TableLayout)findViewById(R.id.tableLayout);
TextView name = (TextView) findViewById(R.id.nameValue);
TextView age = (TextView) findViewById(R.id.ageValue);
TextView eduText = (TextView) findViewById(R.id.spinner);
TextView gender = (TextView) findViewById(R.id.genderValue);
View tableRow= LayoutInflater.from(this).inflate(R.layout.table_item,null,false);
TextView student_display_name1 = (TextView) tableRow.findViewById(R.id.student_display_name);
TextView student_display_age1 = (TextView) tableRow.findViewById(R.id.student_display_age);
TextView student_display_gender1 = (TextView) tableRow.findViewById(R.id.student_display_gender);
TextView student_display_edu1 = (TextView) tableRow.findViewById(R.id.student_display_edu);
((TextView) tableRow.findViewById(R.id.student_display_name)).setText(name.getText());
((TextView) tableRow.findViewById(R.id.student_display_age)).setText(age.getText());
((TextView) tableRow.findViewById(R.id.student_display_gender)).setText(gender.getText());
((TextView) tableRow.findViewById(R.id.student_display_edu)).setText(eduText.getText());
student_display_edu1.setText(student_display_edu);
student_display_name1.setText(student_display_name);
student_display_gender1.setText(student_display_gender);
student_display_age1.setText(student_display_age);
tableLayout.addView(tableRow);
}
}`
and my table_item.xml file is
'
Blockquote
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:orientation="vertical"
android:collapseColumns="0">
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="384dp"
android:layout_height="106dp">
<TextView
android:id="@+id/student_display_gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2" />
<TextView
android:id="@+id/student_display_age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginTop="0dp" />
<TextView
android:id="@+id/student_display_edu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3" />
<TextView
android:id="@+id/student_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="4" />
</TableRow>
</TableLayout>
</RelativeLayout>'
' The error is showing because of the following code
student_display_edu1.setText(student_display_edu);
student_display_name1.setText(student_display_name);
student_display_gender1.setText(student_display_gender);
student_display_age1.setText(student_display_age); '
please help me. I'm stuck here.
enter code here }