android - second fragment run in first fragment and third in second -


my requierment when click button in firstfragment load meaning database ,then screen move next screen (swipe secondfragment) automaticaly image load given url , display in image, swipe thirdfragment automatically audio load given url, , same task video.

given code imagefragment(second fragment) load in meaningfragment(first fragment) , third in second, , fourth in third.

***meaning fragment( first fragment)***  string url2 = ""; string webdata = ""; int wifi = 0; int first = 1; view view; list<string> wordslist; imagebutton find; edittext word; webview data; textview urdu_meaning; listview lv;  sqllitedbhelper dbhelper; getmeaning urdu ; networkinfo mwifi; connectivitymanager connmanager; wifimanager wifimanager; public static string urlword = "";     @override     public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {                 // view fragmenttab1.xml         view = inflater.inflate(r.layout.meaningview, container, false);         word = (edittext) view.findviewbyid(r.id.word);         find = (imagebutton) view.findviewbyid(r.id.find);         data = (webview) view.findviewbyid(r.id.web);         urdu_meaning = (textview) view.findviewbyid(r.id.urdu_text);         lv = (listview) view.findviewbyid(r.id.listofword);         typeface tf= typeface.createfromasset(getactivity().getassets(), "jameel.ttf");         urdu_meaning.settypeface(tf);          if(first == 1)         {             try {                 dbhelper = new sqllitedbhelper(getactivity());                 dbhelper.copydatabasefromasset();             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();              }             first++;          }         word.addtextchangedlistener(new textwatcher() {              @suppresswarnings("static-access")             @suppresslint("inlinedapi")             @override             public void ontextchanged(charsequence s, int start, int before, int count) {                 // todo auto-generated method stub                 if (!word.gettext().tostring().equalsignorecase(""))                  {                      wordslist = dbhelper.loadwords(word.gettext().tostring());                     //wordslist.tostring()                     arrayadapter<string> adapter = new arrayadapter<string>(getactivity(), android.r.layout.simple_selectable_list_item, wordslist);                     lv.setvisibility(view.visible);                     lv.setadapter(adapter);                     data.setvisibility(view.invisible);                     urdu_meaning.setvisibility(view.invisible);                 }             }              @override             public void beforetextchanged(charsequence s, int start, int count,                     int after) {                 // todo auto-generated method stub              }              @override             public void aftertextchanged(editable s) {                 // todo auto-generated method stub              }         });         lv.setonitemclicklistener(new onitemclicklistener() {              @suppresswarnings("static-access")             @override             public void onitemclick(adapterview<?> parent, view view,                     int position, long id) {                 // todo auto-generated method stub                 word.settext(wordslist.get(position));                 lv.setvisibility(view.invisible);             }         });          find.setonclicklistener(new onclicklistener() {             @suppresswarnings("static-access")             @suppresslint({ "newapi", "defaultlocale" })             @override             public void onclick(view v) {                 // todo auto-generated method stub                 mwifi = connmanager.getnetworkinfo(connectivitymanager.type_wifi);                 lv.setvisibility(view.invisible);                 data.setvisibility(view.visible);                 urdu_meaning.setvisibility(view.visible);                  url2 = word.gettext().tostring().tolowercase();                  audiofragment.audioclick = 0;                 videofragment.videoclick = 0;                 imagefragment.imageclick = 0;                 urlword = url2;                 inputmethodmanager inputmanager = (inputmethodmanager) getactivity().getsystemservice(context.input_method_service);                 inputmanager.hidesoftinputfromwindow(view.getwindowtoken(), inputmethodmanager.hide_not_always);                   if(url2.isempty())                 {                     toast.maketext(getactivity(), "word missing! ", toast.length_long).show();                 }                 else                 {                     try{                          urdu = dbhelper.getdetail(word.gettext().tostring());                         urdu_meaning.settext(urdu.meaning.tostring());                     }catch(exception e){                         e.printstacktrace();                         urdu_meaning.settext("urdu word not found");                     }                       if (mwifi.isconnected())                     {                         data.loadurl(url1 + url2);                     }                     else                     {                         toast.maketext(getactivity(), "network problem", toast.length_long).show();                         //wifimanager.setwifienabled(true);                      }                 }              }         });          return view;     }  ***image fragment second fragment***  if(imageclick == 0)         {             //imageurl1 = imageurl + meaningfragment.urlword + ".jpg";             word.setvisibility(view.invisible);             // execute task             //getxmltask task = new getxmltask();             //task.execute(imageurl1);             // create object subclass of asynctask         }          find.setonclicklistener(new onclicklistener() {              @suppresswarnings("static-access")             @suppresslint({ "newapi", "defaultlocale" }) @override             public void onclick(view v) {                  if(imageclick == 0)                 {                     imageurl2 = meaningfragment.urlword.tostring().tolowercase();                     word.setvisibility(view.visible);                     word.settext(meaningfragment.urlword.tostring().tolowercase());                     prevword.setvisibility(view.invisible);                 }                 else                 {                     word.setvisibility(view.visible);                     prevword.setvisibility(view.invisible);                     imageurl2 = word.gettext().tostring().tolowercase();                  }                  mwifi = connmanager.getnetworkinfo(connectivitymanager.type_wifi);                  inputmethodmanager inputmanager = (inputmethodmanager) getactivity().getsystemservice(context.input_method_service);                 inputmanager.hidesoftinputfromwindow(view.getwindowtoken(), inputmethodmanager.hide_not_always);                 if(imageurl2.isempty())                 {                     toast.maketext(getactivity(), "word missing! ", toast.length_long).show();                     imageview.setvisibility(view.invisible);                 }                 else                 {                      imageurl2 = imageurl2 + ".jpg";                     imageurl1 = (imageurl + imageurl2);                     //searchurdu();                       if(mwifi.isconnected())                     {                          try{                               // execute task                             getxmltask task = new getxmltask();                             task.execute(imageurl1);                             // create object subclass of asynctask                            }catch(exception e){                             e.printstacktrace();                          }                          //task.execute("http://www.learn2crack.com/wp-content/uploads/2014/04/node-cover-720x340.png");                          // todo auto-generated method stub                      }                     else                     {                                    toast.maketext(getactivity(), "network problem", toast.length_long).show();                         //wifimanager.setwifienabled(true);                     }                 }              }           });          return view;     }      private class getxmltask extends asynctask<string, void, bitmap> {         @override         protected bitmap doinbackground(string... urls) {             try{                 bitmap map = null;                 (string url : urls) {                     map = downloadimage(url);                 }return map;             }catch(exception e){                 e.printstacktrace();                  return null;             }             }          @override         protected void onpreexecute() {             // todo auto-generated method stub             //pdialog.show();         }         // sets bitmap returned doinbackground         @override         protected void onpostexecute(bitmap result) {             imageview.setimagebitmap(result);             imageview.setvisibility(view.visible);             pdialog.dismiss();             if(result == null){                 toast.maketext(getactivity(), "image not found", toast.length_long).show();             }          }          // creates bitmap inputstream , returns         private bitmap downloadimage(string url) {             try {bitmap bitmap = null;             inputstream stream = null;             bitmapfactory.options bmoptions = new bitmapfactory.options();             bmoptions.insamplesize = 1;               stream = gethttpconnection(url);             bitmap = bitmapfactory.                     decodestream(stream, null, bmoptions);             stream.close();             return bitmap;             } catch (ioexception e1) {                 e1.printstacktrace();                  return null;             }           }          // makes httpurlconnection , returns inputstream         private inputstream gethttpconnection(string urlstring)                 throws ioexception {             try {inputstream stream = null;             url url = new url(urlstring);             urlconnection connection = url.openconnection();               httpurlconnection httpconnection = (httpurlconnection) connection;             httpconnection.setrequestmethod("get");             httpconnection.connect();              if (httpconnection.getresponsecode() == httpurlconnection.http_ok) {                 stream = httpconnection.getinputstream();             }return stream;             } catch (exception ex) {                 ex.printstacktrace();                 toast.maketext(getactivity(), " word not found", toast.length_long).show();                 return null;              }   , same method audio , video..... 


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -