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?
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
add a comment |
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
add a comment |
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
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
android json variables null
edited Mar 21 at 16:41
Zoe
13k85085
13k85085
asked Mar 21 at 16:36
M. Rifqi AziziM. Rifqi Azizi
64
64
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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