incorrect parsing of JSON into ArrayList
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to fill an Android Spinner given some sql generated json in a PHP.
I have already generated with PHP a JSON like this:
{
num: [
{
id: 123
},
{
id: 456
}
]
}
I need to get the Android Client Spinner populated with 123 and 456, but I just get the Spinner populated with only one line (that incidentally contains two ids), I did this:
ArrayList<String> LineArray = new ArrayList<String>();
LineArray.add(responsej.optString("num"));
Spinner myspinner;
myspinner = (Spinner) findViewById(R.id.my_spinner) ;
myspinner.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_dropdown_item, LineArray));
responsej is the JSONObject that I get with JsonHttpResponseHandler. Any suggestions how to get the Client to understand that each id should get populated?
json arraylist android-arrayadapter android-spinner android-json
add a comment |
I am trying to fill an Android Spinner given some sql generated json in a PHP.
I have already generated with PHP a JSON like this:
{
num: [
{
id: 123
},
{
id: 456
}
]
}
I need to get the Android Client Spinner populated with 123 and 456, but I just get the Spinner populated with only one line (that incidentally contains two ids), I did this:
ArrayList<String> LineArray = new ArrayList<String>();
LineArray.add(responsej.optString("num"));
Spinner myspinner;
myspinner = (Spinner) findViewById(R.id.my_spinner) ;
myspinner.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_dropdown_item, LineArray));
responsej is the JSONObject that I get with JsonHttpResponseHandler. Any suggestions how to get the Client to understand that each id should get populated?
json arraylist android-arrayadapter android-spinner android-json
add a comment |
I am trying to fill an Android Spinner given some sql generated json in a PHP.
I have already generated with PHP a JSON like this:
{
num: [
{
id: 123
},
{
id: 456
}
]
}
I need to get the Android Client Spinner populated with 123 and 456, but I just get the Spinner populated with only one line (that incidentally contains two ids), I did this:
ArrayList<String> LineArray = new ArrayList<String>();
LineArray.add(responsej.optString("num"));
Spinner myspinner;
myspinner = (Spinner) findViewById(R.id.my_spinner) ;
myspinner.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_dropdown_item, LineArray));
responsej is the JSONObject that I get with JsonHttpResponseHandler. Any suggestions how to get the Client to understand that each id should get populated?
json arraylist android-arrayadapter android-spinner android-json
I am trying to fill an Android Spinner given some sql generated json in a PHP.
I have already generated with PHP a JSON like this:
{
num: [
{
id: 123
},
{
id: 456
}
]
}
I need to get the Android Client Spinner populated with 123 and 456, but I just get the Spinner populated with only one line (that incidentally contains two ids), I did this:
ArrayList<String> LineArray = new ArrayList<String>();
LineArray.add(responsej.optString("num"));
Spinner myspinner;
myspinner = (Spinner) findViewById(R.id.my_spinner) ;
myspinner.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_dropdown_item, LineArray));
responsej is the JSONObject that I get with JsonHttpResponseHandler. Any suggestions how to get the Client to understand that each id should get populated?
json arraylist android-arrayadapter android-spinner android-json
json arraylist android-arrayadapter android-spinner android-json
asked Nov 17 '18 at 7:15
TiuttoTiutto
916
916
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Make to Model classes like this
Num.class
public class Num
{
public int id { get; set; }
}
SpinnerData.class
public class RootObject
{
public List<Num> num { get; set; }
}
Then parse data to this model
add a comment |
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%2f53349087%2fincorrect-parsing-of-json-into-arraylist%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Make to Model classes like this
Num.class
public class Num
{
public int id { get; set; }
}
SpinnerData.class
public class RootObject
{
public List<Num> num { get; set; }
}
Then parse data to this model
add a comment |
Make to Model classes like this
Num.class
public class Num
{
public int id { get; set; }
}
SpinnerData.class
public class RootObject
{
public List<Num> num { get; set; }
}
Then parse data to this model
add a comment |
Make to Model classes like this
Num.class
public class Num
{
public int id { get; set; }
}
SpinnerData.class
public class RootObject
{
public List<Num> num { get; set; }
}
Then parse data to this model
Make to Model classes like this
Num.class
public class Num
{
public int id { get; set; }
}
SpinnerData.class
public class RootObject
{
public List<Num> num { get; set; }
}
Then parse data to this model
answered Nov 19 '18 at 10:23
Jins LukoseJins Lukose
768418
768418
add a comment |
add a comment |
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%2f53349087%2fincorrect-parsing-of-json-into-arraylist%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