Tool to auto generate Class fields of 'View' type from layout XML?
I'm using eclipse Android SDK, as i can see there are code generator tool
builtin to generate getters() and setters() from the current class. I'd
like to know if there are such tools to auto generate Android View class
instances, into the current class from a given layout. Possibly auto
instantiate them in the onCreate() call back.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
tools:context=".Main" >
<TextView
style="@style/Divider_Title"
android:text="@string/pi_name_title" />
<View style="@style/Divider" />
<EditText
android:id="@+id/et_firstname"
style="@style/EditText"
android:hint="@string/pi_first_name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/et_lastname"
style="@style/EditText"
android:hint="@string/pi_last_name"
android:inputType="textPersonName" />
....
would generate for an already existing class SignIn
public class SignIn extends FragmentActivity {
private EditText et_firstname;
private EditText et_lastname;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
et_firstname = (EditText) findViewById(R.id.et_firstname);
et_lastname = (EditText) findViewById(R.id.et_lastname);
...
}
No comments:
Post a Comment