Android DialogFragment onResume can't access views? -


i'm doing in wrong place, have dialogfragment represents dialog camera button (among other things) , i'm using built-in camera app (calling via intent) returns dialogfragment's onactivityresult().

this works great, goal find attachments linearlayout in dialog , attach copy of captured image it. e.g. takes pics , appear in dialog's "attachments" section.

the issue appears when dialogfragment's onactivityresult() triggered, i'm unable view, it's null:

@override public void onactivityresult(int requestcode, int resultcode, intent data) {     if (requestcode == camera_pic_request && resultcode == activity.result_ok) {                try {                   linearlayout attachments = (linearlayout) getview().findviewbyid(r.id.landmarkattachmentview); // <- getview() null 

i threw in debug log in couple of suspect methods thought might trigger when camera returned, had dialogfragment's view available, none of them logged:

@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     log.d(tag, "creating landmark dialog view");     if(getview() == null) log.d(tag, "no view!");     return super.oncreateview(inflater, container, savedinstancestate); }  @override public void show(fragmentmanager manager, string tag) {     log.d(tag, "show landmark dialog view");             if(getview() == null) log.d(tag, "no view!");     super.show(manager, tag); }  @override public void onviewstaterestored(bundle savedinstancestate) {     log.d(tag, "restored landmark dialog view");             if(getview() == null) log.d(tag, "no view!");     super.onviewstaterestored(savedinstancestate); }  public void onresume() {     log.d(tag, "resume landmark dialog view");             if(getview() == null) log.d(tag, "no view!");     super.onresume(); }  @override public void onstart() {     log.d(tag, "start landmark dialog view");             if(getview() == null) log.d(tag, "no view!");     super.onstart(); } 

only onstart , onresume triggered this.view null. how can dialogfragment's view after it's returned activity/fragment?

thanks!

you need override oncreateview(), create view there , return back. available in other methods too.

public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     return inflater.inflate(r.layout.<your_view_layout>, container, false); } 

here more documentation , example: http://developer.android.com/reference/android/app/dialogfragment.html


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -