java - json value and use it as search suggestion -


is there way me value of vehicle arraylist , show search suggestion here? getting null pointer value..

main activity

    @override     public boolean oncreateoptionsmenu(menu menu) {         //create search view         searchview searchview = new searchview(getsupportactionbar().getthemedcontext());         searchview.setmaxwidth(integer.max_value);         searchview.setqueryhint("what vehicle plate no.?");         searchview.setonquerytextlistener(this);         searchview.setonsuggestionlistener(this);         string container = "";         if (msuggestionsadapter == null) {             matrixcursor cursor = new matrixcursor(columns);  //            ah = vehicle;             (int = 0; < ah.size(); i++) {                 container = container + ah.tostring();                 string = string.valueof(i);                 cursor.addrow(new string[]{is, ah.get(0).get("plate_num").tostring()});             }              msuggestionsadapter = new suggestionsadapter(getsupportactionbar().getthemedcontext(), cursor);         }         toast.maketext(this, vehicle.get(0).get("plate_num").tostring() + "a", toast.length_short).show();         searchview.setsuggestionsadapter(msuggestionsadapter);           menu.add("search")                 .seticon(true ? r.drawable.ic_action_action_search : r.drawable.ic_action_action_search)                 .setactionview(searchview)                 .setshowasaction(menuitem.show_as_action_if_room | menuitem.show_as_action_collapse_action_view);          return true;     }      msuggestionsadapter = new suggestionsadapter(getsupportactionbar().getthemedcontext(), cursor); 

on vehiclefragment on class getting value. declare vehicle public static , variable.

public static arraylist<hashmap<string, string>> vehicle;  public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);  }   private class getvehicles extends asynctask<void, void, void> {      @override     protected void onpreexecute() {         super.onpreexecute();         // showing progress dialog         pdialog = new progressdialog(getactivity());         pdialog.setmessage("please wait...");         pdialog.setcancelable(false);         pdialog.show();      }      @override     protected void doinbackground(void... arg0) {         httphandler sh = new httphandler();          // making request url , getting response         string jsonstr = sh.makeservicecall(url);          string plate_num = "",                 gps_num = "",                 location = "",                 date = "",                 time = "",                 lat = "",                 lng = "",                 engine = "",                 remarks = "";              try {                 jsonarray jr = new jsonarray(jsonstr);                  vehicle = new arraylist<>();                 for(int i=0;i<jsonstr.length();i++) {                     jsonobject jb = (jsonobject)jr.getjsonobject(i);                     plate_num = jb.getstring("plate_num");                     gps_num = jb.getstring("gps_num");                     location = jb.getstring("location");                     date = jb.getstring("date");                     time = jb.getstring("time");                     lat = jb.getstring("lat");                     lng = jb.getstring("lng");                     engine = jb.getstring("engine");                     remarks = jb.getstring("remarks");                      // tmp hash map detail [single]                     hashmap<string, string> details = new hashmap<>();                      // adding each child node hashmap key => value                     details.put("plate_num", plate_num);                     details.put("gps_num", gps_num);                     details.put("location", location);                     details.put("date", date);                     details.put("time", time);                     details.put("lat", lat);                     details.put("lng", lng);                     details.put("engine", engine);                     details.put("remarks", remarks);                      = details.get("date");                      // adding vehicle vehicle list                     vehicle.add(details);                 } 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -