ironmantis7x
ironmantis7x

Reputation: 827

How do I key in an action of a edit text box in android?

Based on the following main.xml code (snippet below), how do I get the java code in the class to save the data that the user types in??

<TextView 
                        android:id="@+id/textview1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" 
                    android:text="year of car" />
            <EditText
                      android:id="@+id/myeditfield"
                      android:layout_width="100px"
                      android:layout_height="wrap_content" />
            <TextView 
                    android:id="@+id/textview1_1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" 
                    android:text="make of car" />
            <EditText
                android:id="@+id/myeditfield"
                android:layout_width="200px"
                android:layout_height="wrap_content" />
            <TextView 
                    android:id="@+id/textview1_2"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" 
                    android:text="model of car" />
            <EditText
                android:id="@+id/myeditfield"
                android:layout_width="200px"
                android:layout_height="wrap_content" /> 

Thanks!!

ironmantis7x

Upvotes: 0

Views: 239

Answers (1)

Rohit Mandiwal
Rohit Mandiwal

Reputation: 10462

TextView tv = (TextView)findViewById(R.id.textview1_2);
String txt =tv.getText().toString();

Upvotes: 1

Related Questions