Skip to content Skip to sidebar Skip to footer

Layoutinflater Doesn't Seem To Be Linked With Id In Layout

I am completely lost with this LayoutInflater. I am trying to link items in code with items located in a remote layout. I have tried three different versions of the inflater creati

Solution 1:

Now that I can see your whole question :-)

LinearLayoutlayout= (LinearLayout) li.inflate( R.layout.linearLayout1, null); 
 TableRowtableRow= (TableRow) linearLayout1.findViewById(R.layout.tableRow2); 
 ImageButtoneditBrowseButton= (ImageButton) tableRow.findViewById(R.id.imageButton1); 

Solution 2:

I'm not sure what are you trying to do. AFAIK LayoutInflater is for "creating views" from resource xml files. Well at least that's what I use it for :D.

First "A TableRow should always be used as a child of a TableLayout" - so the xml looks funny too me - simple LinearLayout would be good. (but that's not on the side)

Anyhow - problem I see with the code is that the view that you inflate is not attached (2nd paramenter is null, and than you leave it hanging).

If you want to duplicate the entry - create it n-times you should do it like this:

setContentView(R.layout.browse);

LayoutInflaterli= (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayoutrow= li.inflate(R.layout.row, null);
findViewById(/*id of element you want the row to be added to*/).add(row); //now row is attachedfinalImageButtoneditBrowseButton= (ImageButton) row.findViewById(R.id.imageButton1); //so this is live, visible etc
editBrowseButton.setAlpha(50); //this should work than

Post a Comment for "Layoutinflater Doesn't Seem To Be Linked With Id In Layout"