android - Is it possible to inflate a CustomLayout : FrameLayout in Xamarin in its own constructors and own class methods? -



android - Is it possible to inflate a CustomLayout : FrameLayout in Xamarin in its own constructors and own class methods? -

here illustration inflate... framelayout , have layout axml file... inflate layout parent of framelayout (a fragment)... want custom framelayout in other fragments. in method initialize() compiler says error cs1604: cannot assign '' because read-only (cs1604) (myproject.mono) , error cs0266: cannot implicitly convert type 'android.widget.framelayout' 'myproject.mono.viewartistalbumtrack'. explicit conversion exists (are missing cast?) (cs0266) (navi.mono)

/// <summary> /// view artist album track. /// framelayout especific ... /// </summary> public class viewartistalbumtrack : framelayout { /// <summary> /// adapter. /// </summary> public expandableaatitemadapter adapter = null; /// <summary> /// plain expandablelistview /// </summary> public expandablelistview expandable = null; /// <summary> /// view triggers sliding /// </summary> public button albumdown = null; public button trackdown = null; /// <summary> /// list aat items. aat artist album track /// </summary> public list<aatitem> list = null; public viewartistalbumtrack (context context) : base of operations (context) { this.trackdown = new button(this.context); this.albumdown = new button(this.context); this.expandable = new expandablelistview(this.context); initialize (); } public viewartistalbumtrack (context context, iattributeset attrs) : base of operations (context, attrs) { this.trackdown = new button(this.context); this.albumdown = new button(this.context); this.expandable = new expandablelistview(this.context); initialize (); } public viewartistalbumtrack (context context, iattributeset attrs, int defstyle) : base of operations (context, attrs, defstyle) { initialize (); } public void initialize () { seek { layoutinflater inflater = (layoutinflater)this.context.getsystemservice(context.layoutinflaterservice); = (framelayout)inflater.inflate(resource.layout.viewaat, null); console.writeline("done succesfully: "+ system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring() ); } catch(exception exception) { console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring() + " : " + exception.source.tostring() ); console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring()+ " : " + exception.message.tostring() ); console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring()+ " : " + exception.stacktrace.tostring() ); console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring()+ " : " + exception.targetsite.tostring() ); }// end of catch() //this.expandable.setadapter(new expandableaatitemadapter(application.context, this.list)); } protected override void onfinishinflate() { seek { this.trackdown = new button(this.context); this.albumdown = new button(this.context); this.expandable = new expandablelistview(this.context); this.expandable = findviewbyid<expandablelistview> (resource.id.aatexpandableid); this.trackdown = findviewbyid<button> (resource.id.aattracksbid); this.albumdown = findviewbyid<button> (resource.id.aatabumsbid); this.trackdown.visibility = viewstates.gone; this.albumdown.visibility = viewstates.gone; console.writeline("done succesfully: "+ system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring() ); } catch(exception exception) { console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring() + " : " + exception.source.tostring() ); console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring()+ " : " + exception.message.tostring() ); console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring()+ " : " + exception.stacktrace.tostring() ); console.writeline ("exception @ " + system.reflection.methodbase.getcurrentmethod().declaringtype.tostring()+ " " + system.reflection.methodbase.getcurrentmethod().name.tostring()+ " : " + exception.targetsite.tostring() ); }// end of catch() }

}

i think issue may line:

= (framelayout)inflater.inflate(resource.layout.viewaat, null);

that isn't right way load layout in view. if view custom framelayout kid views inflate xml framelayout , take references views within e.g.

var frame = (framelayout)inflater.inflate(resource.layout.viewaat, null); this.trackdown = frame.findviewbyid<button>(...); // find other views here

android xamarin custom-controls layout-inflater framelayout

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -