Skip to content

Instantly share code, notes, and snippets.

Created January 18, 2016 03:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mnafian/ec8fa940dddda9880712 to your computer and use it in GitHub Desktop.
private RelativeLayout drawInsideEditor;
RelativeLayout mainLayout;
// oncreate
drawInsideEditor = (RelativeLayout) View.inflate(this, R.layout.dp_text_editor_layout, null);
RelativeLayout drawText = (RelativeLayout) View.inflate(this, R.layout.dp_item_textview_preview, null);
drawInsideEditor.addview(drawText); //ini sukses
mainLayout.addview(drawText); // ini NPE
void updateview(RelativeLayout main){
for (int i = 0; i < main.getChildCount(); i++) {
View viewLayout = main.getChildAt(i);
ImageButton edit = (ImageButton) viewLayout.findViewById(;
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