android - LayoutInflater doesn't seem to be linked with id in layout -
i lost layoutinflater. trying link items in code items located in remote layout. have tried 3 different versions of inflater creation. none of them work. however, version seems used. here snippet of inflater garble:
setcontentview(r.layout.browse); layoutinflater li = (layoutinflater) this.getsystemservice(context.layout_inflater_service); final imagebutton editbrowsebutton = (imagebutton) li.inflate(r.layout.row, null).findviewbyid(r.id.imagebutton1); editbrowsebutton.setalpha(50);
this feels kinda missing something. need return something? .setalpha has no meaning. put in test inlater. obviously, doesn't change transparency. , if add onclicklistner, doesn't work. however, don't exception. activity starts fine. here relevant xml code row.xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearlayout1" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:focusable="true" > <tablerow android:id="@+id/tablerow1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:focusable="true" > <textview android:id= "@+id/txtitem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text = "item" android:focusable="true" /> </tablerow> <tablerow android:id="@+id/tablerow2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:focusable="false" > <imagebutton android:src="@drawable/editbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton1" ></imagebutton> </tablerow> </linearlayout>
edit_01
new approach tried , failed. same results. nothing happens.
setcontentview(r.layout.browse); layoutinflater li = (layoutinflater) .getsystemservice(context.layout_inflater_service); viewgroup rowview = (viewgroup) li.inflate(r.layout.row, null); linearlayout rowlinlay = (linearlayout) rowview .findviewbyid(r.id.linearlayout1); tablerow rowtablerow = (tablerow)rowlinlay.findviewbyid(r.id.tablerow2); imagebutton editbrowsebutton = (imagebutton) rowtablerow .findviewbyid(r.id.imagebutton1);
edit_02
setcontentview(r.layout.browse); expandablelistview browseview = (expandablelistview) findviewbyid(android.r.id.list); layoutinflater li = (layoutinflater) .getsystemservice(context.layout_inflater_service); view rowview = (view) li.inflate(r.layout.row, null); tablerow rowtable = (tablerow) rowview.findviewbyid(r.id.tablerow2); imagebutton editbrowsebutton = (imagebutton) rowtable .findviewbyid(r.id.imagebutton1); editbrowsebutton.setalpha(100);
now can see whole question :-)
linearlayout layout = (linearlayout) li.inflate( r.layout.linearlayout1, null); tablerow tablerow = (tablerow) linearlayout1.findviewbyid(r.layout.tablerow2); imagebutton editbrowsebutton = (imagebutton) tablerow.findviewbyid(r.id.imagebutton1);
Comments
Post a Comment