• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Convert XML layout to java code

Kumidan

Newbie
I'm trying to convert this 4 XML elements to put them into the java class, but I don't know how to do it, can anyone help me?
Code:
    <TextView
        android:id="@+id/text_route_section_station"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="First station"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ImageView
        android:id="@+id/image_route_section_line"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/text_route_section_station"
        android:contentDescription="@string/text_route_section_line_img_title"
        android:src="@drawable/tstop" />

    <TextView
        android:id="@+id/text_route_section_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/image_route_section_line"
        android:layout_toRightOf="@+id/image_route_section_line"
        android:layout_marginLeft="10dp"
        android:layout_marginBottom="5dp"
        android:text="54 min"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/text_route_section_line"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/image_route_section_line"
        android:layout_toRightOf="@+id/text_route_section_time"
        android:layout_marginLeft="10dp"
        android:layout_marginBottom="5dp"
        android:text="Line x"
        android:textAppearance="?android:attr/textAppearanceSmall" />
 
Why would you want to? What I mean is, what is your goal, and why do you think you need them in Java?

It's much, much easier to inflate them from XML.

Maybe if you give us some background on what you're trying to do, we can help you find an easy way to do it :)
 
Back
Top Bottom