Skip to content

Instantly share code, notes, and snippets.

@mnafian
Created January 18, 2016 03:34
Show Gist options
  • Save mnafian/ec8fa940dddda9880712 to your computer and use it in GitHub Desktop.
Save mnafian/ec8fa940dddda9880712 to your computer and use it in GitHub Desktop.
private RelativeLayout drawInsideEditor;
@Bind(R.id.dp_main_layout)
RelativeLayout mainLayout;
// oncreate
drawInsideEditor = (RelativeLayout) View.inflate(this, R.layout.dp_text_editor_layout, null);
mainLayout.addView(drawInsideEditor);
RelativeLayout drawText = (RelativeLayout) View.inflate(this, R.layout.dp_item_textview_preview, null);
drawInsideEditor.addview(drawText); //ini sukses
updateView(drawInsideEditor);
//atau
mainLayout.addview(drawText); // ini NPE
updateView(mainLayout);
void updateview(RelativeLayout main){
for (int i = 0; i < main.getChildCount(); i++) {
View viewLayout = main.getChildAt(i);
ImageButton edit = (ImageButton) viewLayout.findViewById(R.id.fab_edit);
edit.setBackground(....) // ini kena NPE kalo pake mainlayout.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment