android dialogfragment - fragment inner static class and gradle issues -


initially getting error "this fragment inner class should static" in following code:

 public class activity4 extends fragmentactivity {      edittext medit;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_activity4);     }       public void selectdate(view view) {     dialogfragment newfragment = new selectdatefragment();     newfragment.show(getsupportfragmentmanager(), "datepicker"); }  public void populatesetdate(int year, int month, int day) {     medit = (edittext) findviewbyid(r.id.edittext);     medit.settext(day + "/" + month + "/" + year); }  //error here @ selectdatefragment public class selectdatefragment extends dialogfragment implements datepickerdialog.ondatesetlistener {      @override     public dialog oncreatedialog(bundle savedinstancestate) {         final calendar calendar = calendar.getinstance();         int yy = calendar.get(calendar.year);         int mm = calendar.get(calendar.month);         int dd = calendar.get(calendar.day_of_month);         return new datepickerdialog(getactivity(), this, yy, mm, dd);     }      public void ondateset(datepicker view, int yy, int mm, int dd) {         populatesetdate(yy, mm + 1, dd);     } } } 

i tried figure out solution & read on post here lint error , can resolved adding gradle file:

lintoptions { abortonerror false } 

but when did that, message "cannot resolve symbol getdefaultproguardfile". gradle file:

apply plugin: 'com.android.application'  android { compilesdkversion 22 buildtoolsversion "22.0.1"  defaultconfig {     applicationid "com.sample.pat1"     minsdkversion 16     targetsdkversion 22     versioncode 1     versionname "1.0" } buildtypes {     release {         minifyenabled false         proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'     } } lintoptions {     abortonerror false } }  dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' } 

and previous error "this fragment inner class should static" still persists. surprisingly app works fine despite this.. know i'm going wrong.. please help!

if don't want rewrite code (to prevent communication activity or holder in general), can mark fragment valid manually:

@suppresslint("validfragment") dialogfragment newfragment = new selectdatefragment(); 

more description why doest happen can find here

p.s. proguard - seems me issue.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -