c# - Reusable Included Layouts -


i've discovered can include .axml layout file inside of using tag. great, allowing encapsulation of common layout themes, i'm wondering whether there way bind code/logic included layout?

my include layout contains few buttons, , i'd each of these buttons take user different activity. obviously, don't want have repeat code inside of each activity there way can write class contains logic included layout , bind it?

if provide example appreciated ;)

you can reuse method have written button there boiler plate code comes it.
can either:

  1. in each activity add method buttons click event.

or

  1. define click method in xml , implement in activities (with base class or individually) so:

the activity

[java.interop.export("somebuttonclick")] public void somebuttonclick(view v) {     yourreusablemethod(); } 

the axml

<button     android:id="@+id/some_btn"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:onclick="somebuttonclick" /> 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -