AutoCompleteTextView onItemClick AdapterView set value is null The Next CEO of Stack OverflowHow to check empty/undefined/null string in JavaScript?Avoiding != null statementsAltering a column: null to not nullWhy is null an object and what's the difference between null and undefined?How to determine if variable is 'undefined' or 'null'?Is null check needed before calling instanceof?null object in Python?How to check if a variable is set in Bash?What is the difference between null and undefined in JavaScript?Is there a standard function to check for null, undefined, or blank variables in JavaScript?

What do "high sea" and "carry" mean in this sentence?

Apart from "berlinern", do any other German dialects have a corresponding verb?

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

Does it take more energy to get to Venus or to Mars?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Can a single photon have an energy density?

Inappropriate reference requests from Journal reviewers

Is HostGator storing my password in plaintext?

How do we know the LHC results are robust?

Why do professional authors make "consistency" mistakes? And how to avoid them?

How can I quit an app using Terminal?

Is a stroke of luck acceptable after a series of unfavorable events?

Text adventure game code

Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?

Should I tutor a student who I know has cheated on their homework?

Unreliable Magic - Is it worth it?

Trouble understanding the speech of overseas colleagues

The King's new dress

When airplanes disconnect from a tanker during air to air refueling, why do they bank so sharply to the right?

How to use tikz in fbox?

Why didn't Khan get resurrected in the Genesis Explosion?

Why do remote companies require working in the US?

Term for the "extreme-extension" version of a straw man fallacy?

Why were Madagascar and New Zealand discovered so late?



AutoCompleteTextView onItemClick AdapterView set value is null



The Next CEO of Stack OverflowHow to check empty/undefined/null string in JavaScript?Avoiding != null statementsAltering a column: null to not nullWhy is null an object and what's the difference between null and undefined?How to determine if variable is 'undefined' or 'null'?Is null check needed before calling instanceof?null object in Python?How to check if a variable is set in Bash?What is the difference between null and undefined in JavaScript?Is there a standard function to check for null, undefined, or blank variables in JavaScript?










0















I have a "Kecamatan" variable.

I want to throw a value from a variable (Kecamatan) to jsonParseDesa.java but the result is always null.
While the variable is obtained from AutoCompleteTextView.



here there "Kecamatan" variables when I display in the log successfully. can display values.
Code setAdapter and setOnItemClickListener :



final KecamatanAdapter adapterKecamatan = new KecamatanAdapter(this, autoKecamatan.getText().toString());
autoKecamatan.setAdapter(adapterKecamatan);
autoKecamatan.setOnItemClickListener(new AdapterView.OnItemClickListener()

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
// TODO Auto-generated method stub
JsonParseKecamatan jps=new JsonParseKecamatan();

Kecamatan selectedSuggestGetSet = adapterKecamatan.getAllUpdatedSuggestion().get(position);
kecamatan = selectedSuggestGetSet.getId().toString();
((JsonParseDesa) XsiswaAddActivity.this.getApplication()).setDistrictId(kecamatan);
Log.d("Kecamatan Result : ", kecamatan);

);


Code JsonParseDesa.java :



public class JsonParseDesa extends Application 

double current_latitude,current_longitude;

private String districtId ;

public String getDistrictId()
return districtId;


public void setDistrictId(String idDistrict)
districtId = idDistrict;


public JsonParseDesa()

public JsonParseDesa(double current_latitude, double current_longitude)
this.current_latitude=current_latitude;
this.current_longitude=current_longitude;


public List<Desa> getParseJsonDesa(String sName)

List<Desa> ListData = new ArrayList<Desa>();
try
String temp = sName.replace(" ", "%20");
URL js = new URL("http://examplewebservice.com/api/public/village/"+districtId+"/"+temp);
URLConnection jc = js.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
String line = reader.readLine();
JSONObject jsonResponse = new JSONObject(line);
JSONArray jsonArray = jsonResponse.getJSONArray("desa_kecamatan_rbg");
for(int i = 0; i < jsonArray.length(); i++)
JSONObject r = jsonArray.getJSONObject(i);
ListData.add(new Desa(r.getString("id"),r.getString("district_id"),r.getString("name")));

Log.d("URL Result : ", js.toString());
catch (Exception e1)
// TODO Auto-generated catch block
e1.printStackTrace();

return ListData;




Log Results:



03-21 23:23:31.165 28230-28230/com.example.test.test I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
03-21 23:23:31.499 28230-28459/com.example.test.test D/OpenGLRenderer: endAllStagingAnimators on 0x558a4aa460 (RippleDrawable) with handle 0x558a53f110
03-21 23:23:38.681 28230-28538/com.example.test.test I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
03-21 23:23:39.367 28230-28230/com.example.test.test D/Kecamatan Result :: 3317100
03-21 23:23:39.380 28230-28230/com.example.test.test W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
03-21 23:23:41.995 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/S
03-21 23:23:42.071 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Su
03-21 23:23:42.310 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Sum
03-21 23:23:44.026 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summ
03-21 23:23:44.196 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summm


Why is the String districtId null? where is the code error? thanks.










share|improve this question




























    0















    I have a "Kecamatan" variable.

    I want to throw a value from a variable (Kecamatan) to jsonParseDesa.java but the result is always null.
    While the variable is obtained from AutoCompleteTextView.



    here there "Kecamatan" variables when I display in the log successfully. can display values.
    Code setAdapter and setOnItemClickListener :



    final KecamatanAdapter adapterKecamatan = new KecamatanAdapter(this, autoKecamatan.getText().toString());
    autoKecamatan.setAdapter(adapterKecamatan);
    autoKecamatan.setOnItemClickListener(new AdapterView.OnItemClickListener()

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id)
    // TODO Auto-generated method stub
    JsonParseKecamatan jps=new JsonParseKecamatan();

    Kecamatan selectedSuggestGetSet = adapterKecamatan.getAllUpdatedSuggestion().get(position);
    kecamatan = selectedSuggestGetSet.getId().toString();
    ((JsonParseDesa) XsiswaAddActivity.this.getApplication()).setDistrictId(kecamatan);
    Log.d("Kecamatan Result : ", kecamatan);

    );


    Code JsonParseDesa.java :



    public class JsonParseDesa extends Application 

    double current_latitude,current_longitude;

    private String districtId ;

    public String getDistrictId()
    return districtId;


    public void setDistrictId(String idDistrict)
    districtId = idDistrict;


    public JsonParseDesa()

    public JsonParseDesa(double current_latitude, double current_longitude)
    this.current_latitude=current_latitude;
    this.current_longitude=current_longitude;


    public List<Desa> getParseJsonDesa(String sName)

    List<Desa> ListData = new ArrayList<Desa>();
    try
    String temp = sName.replace(" ", "%20");
    URL js = new URL("http://examplewebservice.com/api/public/village/"+districtId+"/"+temp);
    URLConnection jc = js.openConnection();
    BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
    String line = reader.readLine();
    JSONObject jsonResponse = new JSONObject(line);
    JSONArray jsonArray = jsonResponse.getJSONArray("desa_kecamatan_rbg");
    for(int i = 0; i < jsonArray.length(); i++)
    JSONObject r = jsonArray.getJSONObject(i);
    ListData.add(new Desa(r.getString("id"),r.getString("district_id"),r.getString("name")));

    Log.d("URL Result : ", js.toString());
    catch (Exception e1)
    // TODO Auto-generated catch block
    e1.printStackTrace();

    return ListData;




    Log Results:



    03-21 23:23:31.165 28230-28230/com.example.test.test I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
    03-21 23:23:31.499 28230-28459/com.example.test.test D/OpenGLRenderer: endAllStagingAnimators on 0x558a4aa460 (RippleDrawable) with handle 0x558a53f110
    03-21 23:23:38.681 28230-28538/com.example.test.test I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
    03-21 23:23:39.367 28230-28230/com.example.test.test D/Kecamatan Result :: 3317100
    03-21 23:23:39.380 28230-28230/com.example.test.test W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
    03-21 23:23:41.995 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/S
    03-21 23:23:42.071 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Su
    03-21 23:23:42.310 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Sum
    03-21 23:23:44.026 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summ
    03-21 23:23:44.196 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summm


    Why is the String districtId null? where is the code error? thanks.










    share|improve this question


























      0












      0








      0








      I have a "Kecamatan" variable.

      I want to throw a value from a variable (Kecamatan) to jsonParseDesa.java but the result is always null.
      While the variable is obtained from AutoCompleteTextView.



      here there "Kecamatan" variables when I display in the log successfully. can display values.
      Code setAdapter and setOnItemClickListener :



      final KecamatanAdapter adapterKecamatan = new KecamatanAdapter(this, autoKecamatan.getText().toString());
      autoKecamatan.setAdapter(adapterKecamatan);
      autoKecamatan.setOnItemClickListener(new AdapterView.OnItemClickListener()

      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position, long id)
      // TODO Auto-generated method stub
      JsonParseKecamatan jps=new JsonParseKecamatan();

      Kecamatan selectedSuggestGetSet = adapterKecamatan.getAllUpdatedSuggestion().get(position);
      kecamatan = selectedSuggestGetSet.getId().toString();
      ((JsonParseDesa) XsiswaAddActivity.this.getApplication()).setDistrictId(kecamatan);
      Log.d("Kecamatan Result : ", kecamatan);

      );


      Code JsonParseDesa.java :



      public class JsonParseDesa extends Application 

      double current_latitude,current_longitude;

      private String districtId ;

      public String getDistrictId()
      return districtId;


      public void setDistrictId(String idDistrict)
      districtId = idDistrict;


      public JsonParseDesa()

      public JsonParseDesa(double current_latitude, double current_longitude)
      this.current_latitude=current_latitude;
      this.current_longitude=current_longitude;


      public List<Desa> getParseJsonDesa(String sName)

      List<Desa> ListData = new ArrayList<Desa>();
      try
      String temp = sName.replace(" ", "%20");
      URL js = new URL("http://examplewebservice.com/api/public/village/"+districtId+"/"+temp);
      URLConnection jc = js.openConnection();
      BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
      String line = reader.readLine();
      JSONObject jsonResponse = new JSONObject(line);
      JSONArray jsonArray = jsonResponse.getJSONArray("desa_kecamatan_rbg");
      for(int i = 0; i < jsonArray.length(); i++)
      JSONObject r = jsonArray.getJSONObject(i);
      ListData.add(new Desa(r.getString("id"),r.getString("district_id"),r.getString("name")));

      Log.d("URL Result : ", js.toString());
      catch (Exception e1)
      // TODO Auto-generated catch block
      e1.printStackTrace();

      return ListData;




      Log Results:



      03-21 23:23:31.165 28230-28230/com.example.test.test I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
      03-21 23:23:31.499 28230-28459/com.example.test.test D/OpenGLRenderer: endAllStagingAnimators on 0x558a4aa460 (RippleDrawable) with handle 0x558a53f110
      03-21 23:23:38.681 28230-28538/com.example.test.test I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
      03-21 23:23:39.367 28230-28230/com.example.test.test D/Kecamatan Result :: 3317100
      03-21 23:23:39.380 28230-28230/com.example.test.test W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
      03-21 23:23:41.995 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/S
      03-21 23:23:42.071 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Su
      03-21 23:23:42.310 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Sum
      03-21 23:23:44.026 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summ
      03-21 23:23:44.196 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summm


      Why is the String districtId null? where is the code error? thanks.










      share|improve this question
















      I have a "Kecamatan" variable.

      I want to throw a value from a variable (Kecamatan) to jsonParseDesa.java but the result is always null.
      While the variable is obtained from AutoCompleteTextView.



      here there "Kecamatan" variables when I display in the log successfully. can display values.
      Code setAdapter and setOnItemClickListener :



      final KecamatanAdapter adapterKecamatan = new KecamatanAdapter(this, autoKecamatan.getText().toString());
      autoKecamatan.setAdapter(adapterKecamatan);
      autoKecamatan.setOnItemClickListener(new AdapterView.OnItemClickListener()

      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position, long id)
      // TODO Auto-generated method stub
      JsonParseKecamatan jps=new JsonParseKecamatan();

      Kecamatan selectedSuggestGetSet = adapterKecamatan.getAllUpdatedSuggestion().get(position);
      kecamatan = selectedSuggestGetSet.getId().toString();
      ((JsonParseDesa) XsiswaAddActivity.this.getApplication()).setDistrictId(kecamatan);
      Log.d("Kecamatan Result : ", kecamatan);

      );


      Code JsonParseDesa.java :



      public class JsonParseDesa extends Application 

      double current_latitude,current_longitude;

      private String districtId ;

      public String getDistrictId()
      return districtId;


      public void setDistrictId(String idDistrict)
      districtId = idDistrict;


      public JsonParseDesa()

      public JsonParseDesa(double current_latitude, double current_longitude)
      this.current_latitude=current_latitude;
      this.current_longitude=current_longitude;


      public List<Desa> getParseJsonDesa(String sName)

      List<Desa> ListData = new ArrayList<Desa>();
      try
      String temp = sName.replace(" ", "%20");
      URL js = new URL("http://examplewebservice.com/api/public/village/"+districtId+"/"+temp);
      URLConnection jc = js.openConnection();
      BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
      String line = reader.readLine();
      JSONObject jsonResponse = new JSONObject(line);
      JSONArray jsonArray = jsonResponse.getJSONArray("desa_kecamatan_rbg");
      for(int i = 0; i < jsonArray.length(); i++)
      JSONObject r = jsonArray.getJSONObject(i);
      ListData.add(new Desa(r.getString("id"),r.getString("district_id"),r.getString("name")));

      Log.d("URL Result : ", js.toString());
      catch (Exception e1)
      // TODO Auto-generated catch block
      e1.printStackTrace();

      return ListData;




      Log Results:



      03-21 23:23:31.165 28230-28230/com.example.test.test I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
      03-21 23:23:31.499 28230-28459/com.example.test.test D/OpenGLRenderer: endAllStagingAnimators on 0x558a4aa460 (RippleDrawable) with handle 0x558a53f110
      03-21 23:23:38.681 28230-28538/com.example.test.test I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
      03-21 23:23:39.367 28230-28230/com.example.test.test D/Kecamatan Result :: 3317100
      03-21 23:23:39.380 28230-28230/com.example.test.test W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
      03-21 23:23:41.995 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/S
      03-21 23:23:42.071 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Su
      03-21 23:23:42.310 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Sum
      03-21 23:23:44.026 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summ
      03-21 23:23:44.196 28230-28541/com.example.test.test D/URL Result :: http://examplewebservice.com/api/public/village/null/Summm


      Why is the String districtId null? where is the code error? thanks.







      android json variables null






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 21 at 16:41









      Zoe

      13k85085




      13k85085










      asked Mar 21 at 16:36









      M. Rifqi AziziM. Rifqi Azizi

      64




      64






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285229%2fautocompletetextview-onitemclick-adapterview-set-value-is-null%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285229%2fautocompletetextview-onitemclick-adapterview-set-value-is-null%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?