meds
meds

Reputation: 22926

Creating views in XML and Java then referencing and loading them later?

In WPF (Microsoft land I know) you can define a control in XAML (xml-ish thing) along with the controls behaviour in codebehind (C#).

So in an XML file I want to be able to say something like:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res/com.example.mytestapp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

control:name="MyCustomControl" >

<Button />
<stuff>(...)</stuff>
</LinearLayout>

And also have a java source file called MyCustomControl which controls the behaviour of the control defined in the XML file.

Is there an equivalent for android with Java/XML? All I see are things involving custom attributes where you have to write out the entire control in Java still :-/

Upvotes: 1

Views: 85

Answers (2)

user1824644
user1824644

Reputation: 33

You can integrate your android interfaces with XAML and Java, as you use to in WPF. Look at this link for more info about how to do it: http://dotnetslackers.com/articles/net/Android-for-NET-Developers-Building-the-User-Interface.aspx

Upvotes: 1

Daniel Conde Marin
Daniel Conde Marin

Reputation: 7742

Of course, Android is all about JAVA/XML. In fact, normally you design your UI(widgets/controls) in xml files(you can do it also programatically), and then you implement their behavior commonly on classes that extends Activity, an Android built in class. Check this out

Upvotes: 2

Related Questions