I want to parse a JSON file with nested arrays and objects, and use the parsed info to populate a spinner.
Now I'm stuck in the progress window, only showing "loading"...I only want to extract the name tag (navn) to the spinner, and nsrID stored in a variable, for later use.
JSON format:
[
{
"nsrId": "1018038",
"koordinatLatLng": [
59.6908,
9.04228
],
"navn": "Gransherad barnehage",
"fylkesnummer": "08",
"kommunenummer": "0807",
"alder": "1 - 5",
"eierform": "Kommunal",
"antallBarn": 26
},
{
"nsrId": "1012983",
"koordinatLatLng": [
59.5763,
9.19806
],
"navn": "Trolldalen Gårdsbarnehage",
"fylkesnummer": "08",
"kommunenummer": "0807",
"alder": "1 - 5",
"eierform": "Privat",
"antallBarn": 24
},
etc...
My code:
spinner = findViewById(R.id.barneHage_Spinner);
hentJSON();
}
private void hentJSON() {
showSimplProgressDialog(this, "loading...", "Henter Json", false);
StringRequest stringRequest = new StringRequest(Request.Method.GET, barnehager_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.d("strrrrr", ">>" + response);
try {
JSONObject obj = new JSONObject(response);
barnehageArrayList = new ArrayList<>();
JSONArray dataArray = obj.getJSONArray("navn");
for (int i = 0; i < dataArray.length(); i++) {
Barnehage model = new Barnehage();
JSONObject dataobj = dataArray.getJSONObject(i);
model.setNavn(dataobj.getString("navn"));
// model.setNsrId(dataArray.getNsrId(Integer.parseInt("nsrId")));
barnehageArrayList.add(model);
}
for (int i = 0; i < barnehageArrayList.size(); i++) {
names.add(barnehageArrayList.get(i).getNavn());
}
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(BarneHager.this, simple_spinner_item, names);
spinner.setAdapter(spinnerArrayAdapter);
removeSimpleProgressDialog();
} catch (JSONException e) {
e.printStackTrace();
}
}
I expect the output to be a spinner with the only values showing
1: Gransherad barnehage
2: Trolldalen Gårdsbarnehage
3: ..
4: ..
etc
I think you were wrong when getting JSON array by JSONArray dataArray = obj.getJSONArray("navn").
Let try using this code:
#Override
public void onResponse (String response) {
try {
JSONArray dataArray = new JSONArray(response);
for (int i = 0; i < dataArray.length(); i++) {
JSONObject dataobj = dataArray.getJSONObject(i);
You have to add an item at zero position of your list
barnehageArrayList.add(0,new MODELCLASS("Select option"))
And add below code to populate your Spinner
SPINNER_NAME.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position != 0) {
} else {
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
Related
Hi Greetings and Salutations. Am trying to develop an android app that during the signup data is fetched from Json stored at the asset folder and populate it in spinner. In the code i have one spinner and multiple EditView and TextView. In the signup the user select country from the spinner and it should automatically set some values to the TextView or EditView like country code, country phone code, id etc but am finding it difficult to do so, have searched but most people only have two value like id and name while mine has more. The code am modifying i got it somewhere from this site few weeks ago.
i added this to the code
ArrayList<String> countryName = new ArrayList<String>();
ArrayList<String> phoneCode = new ArrayList<String>();
ArrayList<String> countryCode = new ArrayList<String>();
and this
country = jObj.getString("name");
dial_code = jObj.getString("dial_code");
country_code = jObj.getString("code");
countryName.add(country);
phoneCode.add(dial_code);
countryCode.add(country_code);
TextCountry = (TextView) findViewById(R.id.country);
TextDialCode = (TextView) findViewById(R.id.dial_code);
TextCode = (TextView) findViewById(R.id.code);
json_string= loadJSONFromAsset();
ArrayList<String> countryName = new ArrayList<String>();
ArrayList<String> phoneCode = new ArrayList<String>();
ArrayList<String> countryCode = new ArrayList<String>();
{
try {
jsonObj =new JSONObject(json_string);
jsonArray =jsonObj.getJSONArray("countries");
String country, dial_code, country_code;
for (int i = 0; i < jsonArray.length(); i++){
JSONObject jObj = jsonArray.getJSONObject(i);
country = jObj.getString("name");
dial_code = jObj.getString("dial_code");
country_code = jObj.getString("code");
countryName.add(country);
phoneCode.add(dial_code);
countryCode.add(country_code);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_dropdown_item, countryName);
spinner = (Spinner)findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
spinner.setAdapter(adapter);
//TextDialCode.setText((CharSequence) phoneCode);
}
public String loadJSONFromAsset() {
String json = null;
try {
InputStream is = getAssets().open("country_phones.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return json;
}
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
Toast.makeText(LoginActivity.this, parent.getItemAtPosition(position).toString() + " Selected" , Toast.LENGTH_LONG).show();
Country = parent.getItemAtPosition(position).toString();
String Text = String.valueOf(spinner.getSelectedItem());
String catID = String.valueOf(spinner.getSelectedItemId() + 1);
Toast.makeText(LoginActivity.this, Text + catID , Toast.LENGTH_LONG).show();
TextDialCode.setText(catID);
}
Some of my Json data
{
"countries": [
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Albania",
"dial_code": "+355",
"code": "AL"
},
{
"name": "Algeria",
"dial_code": "+213",
"code": "DZ"
},
{
"name": "AmericanSamoa",
"dial_code": "+1 684",
"code": "AS"
},
{
"name": "Andorra",
"dial_code": "+376",
"code": "AD"
},
Please i will love to know how to set name to TextCountry, code to TextCode and dial_code to TextDialCode.
Thanks
I was able to solve it by just trial and error. i had to create a model so that the values will be store there then fetched later on. this is the new code.
ArrayList<String> countryName = new ArrayList<String>();
json_string = loadJSONFromAsset();
{
// Locate the WorldPopulation Class
world = new ArrayList<SignUp>();
// Create an array to populate the spinner
worldlist = new ArrayList<String>();
try {
// JSON file Assert Folder
jsonobject = new JSONObject(json_string);
// Locate the NodeList name
jsonarray = jsonobject.getJSONArray("countries");
for (int i = 0; i < jsonarray.length(); i++) {
jsonobject = jsonarray.getJSONObject(i);
SignUp worldpop = new SignUp();
worldpop.setCountry(jsonobject.optString("name"));
worldpop.setCountry_phone_Code(jsonobject.optString("dial_code"));
worldpop.setCountry_Code(jsonobject.optString("code"));
world.add(worldpop);
// Populate spinner with country names
worldlist.add(jsonobject.optString("name"));
}
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_dropdown_item, worldlist);
spinner = (Spinner)findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
spinner.setAdapter(adapter);
}
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
String CountryPhone = world.get(position).getCountry_phone_Code();
TextDialCode.setText(CountryPhone);
country = world.get(position).getCountry();
}
this is my model
public class SignUp {
public String country;
public String country_code;
public String country_phone_code;
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCountry_Code() {
return country_code;
}
public String getCountry_phone_Code() {
return country_phone_code;
}
public void setCountry_Code(String country_code) {
this.country_code = country_code;
}
public void setCountry_phone_Code(String country_phone_code) {
this.country_phone_code = country_phone_code;
}
}
I am just starting to learn java and Android , Ia m trying to parse json data and apply the data to recyclerview but i am not able to do it. here is my code
public void JSON_DATA_WEB_CALL(){
jsonArrayRequest = new JsonArrayRequest(GET_JSON_DATA_HTTP_URL,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
progressBar.setVisibility(View.INVISIBLE);
JSON_PARSE_DATA_AFTER_WEBCALL(response);
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue = Volley.newRequestQueue(this);
requestQueue.add(jsonArrayRequest);
}
public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array){
for(int i = 0; i<array.length(); i++) {
GetDataAdapter GetDataAdapter2 = new GetDataAdapter();
JSONObject json = null;
try {
json = array.getJSONObject(i);
GetDataAdapter2.setImageTitleNamee(json.getString(JSON_IMAGE_TITLE_NAME));
//GetDataAdapter2.setImageServerLarger(json.getString(JSON_IMAGE_LARGER));
GetDataAdapter2.setImageServerUrl(json.getString(JSON_IMAGE_URL));
GetDataAdapter2.setMrp_price(json.getString(JSON_MRP_PRICE));
GetDataAdapter2.setDisc_price(json.getString(JSON_DISC_PRICE));
} catch (JSONException e) {
e.printStackTrace();
}
GetDataAdapter1.add(GetDataAdapter2);
}
recyclerViewadapter = new RecyclerViewAdapter(GetDataAdapter1, this);
recyclerView.setAdapter(recyclerViewadapter);
}
And here is my JSON Response
{"118":{"garment_color":"Blue","garment_name":"skjhkds","garment_price":"232"},"119":{"garment_color":"hjsadjjs","garment_name":"sdasd","garment_price":"23478"}}
Please someone give a brief explanation of the correct code. it would be very helpful. Thanks
rvAdapter = new RvAdapter(getActivity());
recyclerview.setAdapter(rvAdapterHScode);
rvAdapter.set(responce.getcodes());
recyclerview.setLayoutManager(new GridLayoutManager(getActivity(), 3));
then in adapter
accept the set values
or
call your response inside the recyclerview adapter
like this way
your jsonArray should be in following way:
{
"jArray": [{
"id": "118",
"garment_color": "Blue",
"garment_name": "skjhkds",
"garment_price": "232"
},
{
"id": "119",
"garment_color": "hjsadjjs",
"garment_name": "sdasd",
"garment_price": "23478"
}
]
}
then read that json like this way:
// Getting JSON Array node
JSONArray contacts = jsonObj.getJSONArray("jArray");
// looping through All Contacts
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
try {
GetDataAdapter2.setImageTitleNamee(c.getString("garment_name"));
GetDataAdapter2.setMrp_price(c.getString("garment_price"));
} catch (JSONException e) {
e.printStackTrace();
}
GetDataAdapter1.add(GetDataAdapter2);
}
recyclerViewadapter = new RecyclerViewAdapter(GetDataAdapter1, this);
recyclerView.setAdapter(recyclerViewadapter);
I want use JsonObjectRequest in onItemSelected spinner when set item spinner get json but JsonObjectRequest not work and not display nothing,how to can use JsonObjectRequest in onItemSelected?please help me
my code
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
JsonObjectRequest jsonObjectr = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonArray = response.getJSONArray("list");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = (JSONObject) jsonArray.get(i);
int id = jsonObject.getInt("id");
int id_category = jsonObject.getInt("id_category");
int id_speaker = jsonObject.getInt("id_speaker");
String name = jsonObject.getString("name");
String image = jsonObject.getString("image");
String category_name = jsonObject.getString("category_name");
String speaker_name = jsonObject.getString("speaker_name");
Item_zakerin_any itemzakeran = new Item_zakerin_any(id, id_category, name, id_speaker, image, speaker_name, category_name);
list_zakeran_any.add(itemzakeran);
az = new adapter_zakeran_any(mcontext, list_zakeran_any);
rv.setAdapter(az);
hidepDialog();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
hidepDialog();
}
});
MySingleton.getInstance(getApplicationContext()).addToRequestQueue(jsonObjectr);
}
You are setting your adapter in the loop. Move it out like:
try {
JSONArray jsonArray = response.getJSONArray("list");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = (JSONObject) jsonArray.get(i);
int id = jsonObject.getInt("id");
int id_category = jsonObject.getInt("id_category");
int id_speaker = jsonObject.getInt("id_speaker");
String name = jsonObject.getString("name");
String image = jsonObject.getString("image");
String category_name = jsonObject.getString("category_name");
String speaker_name = jsonObject.getString("speaker_name");
Item_zakerin_any itemzakeran = new Item_zakerin_any(id, id_category, name, id_speaker, image, speaker_name, category_name);
list_zakeran_any.add(itemzakeran);
}
az = new adapter_zakeran_any(mcontext, list_zakeran_any);
rv.setAdapter(az);
hidepDialog();
} catch (JSONException e) {
e.printStackTrace();
hidepDialog();
}
Also don't forget to hide your dialog if it hits exception so they are not permanently blocked.
In Activity B there has a spinner where the data were get from MySQL (Table location).
Activity B
private ArrayList<String> froms;
private JSONArray resultFrom;
public void addItemsOnFrom() {
travelFrom = (Spinner) findViewById(R.id.travelFrom);
StringRequest stringRequest = new StringRequest(Configs.FROM_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
JSONObject j = null;
try {
//Parsing the fetched Json String to JSON Object
j = new JSONObject(response);
//Storing the Array of JSON String to our JSON Array
resultFrom = j.getJSONArray(Configs.JSON_ARRAY);
//Calling method getStudents to get the students from the JSON Array
getFrom(resultFrom);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
//Creating a request queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
//Adding request to the queue
requestQueue.add(stringRequest);
}
private void getFrom(JSONArray j) {
//Traversing through all the items in the json array
for (int i = 0; i < j.length(); i++) {
try {
//Getting json object
JSONObject json = j.getJSONObject(i);
//Adding the name of the student to array list
froms.add(json.getString(Configs.TAG_LOCATION));
} catch (JSONException e) {
e.printStackTrace();
}
}
//Setting adapter to show the items in the spinner
travelFrom.setAdapter(new ArrayAdapter<String>(Add_Details_Information.this, android.R.layout.simple_spinner_dropdown_item, froms));
}
When save button is clicked, it will return the selected value(OFFICE) to Activity A listView. And in Activity A, when the list is pressed, it will intent to Activity B. In this time, the spinner in Activity B will display the selected item first(OFFICE).
**Table location** // table location has 2 data
NONE
OFFICE
Assume OFFICE is selected in B. When list is clicked, I want OFFICE display first in spinner B.
Code in Activity B for display OFFICE first.
if(getIntent().getExtras()!=null)
{
final String from = getIntent().getStringExtra("from");
selectedItemFrom(from);
}
public void selectedItemFrom(final String value)// display OFFICE first
{
travelFrom = (Spinner) findViewById(R.id.travelFrom);
StringRequest stringRequest = new StringRequest(Configs.FROM_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
JSONObject j = null;
try {
//Parsing the fetched Json String to JSON Object
j = new JSONObject(response);
//Storing the Array of JSON String to our JSON Array
result = j.getJSONArray(Configs.JSON_ARRAY);
//Calling method getStudents to get the students from the JSON Array
getFrom(result, value);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
//Creating a request queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
//Adding request to the queue
requestQueue.add(stringRequest);
}
private void getFrom(JSONArray j, String value) {
int position = 0;
//Traversing through all the items in the json array
for (int i = 0; i < j.length(); i++) {
try {
//Getting json object
JSONObject json = j.getJSONObject(i);
//Adding the name of the student to array list
froms.add(json.getString(Configs.TAG_LOCATION));
if (froms.get(i).equalsIgnoreCase(value)) {
position = i;
//Toast.makeText(getApplicationContext(),position+"",Toast.LENGTH_LONG).show();
break;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
travelFrom.setAdapter(new ArrayAdapter<String>(Add_Details_Information.this, android.R.layout.simple_spinner_dropdown_item, froms));
travelFrom.setSelection(position);
}
The OFFICE can display first, but the problem is when I checked the spinner B, it shows NONE,OFFICE,NONE OFFICE ..Why the spinner data will get duplicated ? Thanks
I think problem is in this line travelFrom.setAdapter(new ArrayAdapter<String>(Add_Details_Information.this, android.R.layout.simple_spinner_dropdown_item, froms));...But how to solve??? Anyone?
And sometimes the spinner will display the selected item first but sometimes it will not...What are the better way to write?
Edit
{"result":[{"name":"NONE"},{"name":"OFFICE"}]}
I put forms.clear in beginning of both getFrom method now. But the problem is when I select NONE and return to A, then goes to B again,the spinner now has NONE only...
Please try something like this.
This activity will expect a Intent with the key "from" that is set to either "NONE" or "OFFICE". If the intent does not have the data, then it will default to whatever was inserted into the Spinner first.
public class MainActivity extends AppCompatActivity {
private Spinner travelFrom;
private ArrayAdapter<String> mSpinnerAdapter;
private List<String> mSpinnerData;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String from = null;
Bundle extras = getIntent().getExtras();
if (extras != null) {
from = extras.getString("from");
}
setupFromSpinner(from);
}
private void setupFromSpinner(final String value) {
travelFrom = (Spinner) findViewById(R.id.travelFrom);
mSpinnerData = new ArrayList<String>();
mSpinnerAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, mSpinnerData);
mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
travelFrom.setAdapter(mSpinnerAdapter);
JsonObjectRequest req = new JsonObjectRequest(Configs.FROM_URL,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
mSpinnerData.clear();
try {
JSONArray resultFrom = response.getJSONArray("result");
for (int i = 0; i < resultFrom.length(); i++) {
JSONObject fromObj = resultFrom.getJSONObject(i);
String name = fromObj.getString("name");
mSpinnerData.add(name);
}
mSpinnerAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
if (value != null) {
int position = mSpinnerAdapter.getPosition(value);
travelFrom.setSelection(position);
} else {
travelFrom.setSelection(0);
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}
);
//Creating a request queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
//Adding request to the queue
requestQueue.add(req);
}
}
add froms.clear() to this piece of code;
private void getFrom(JSONArray j) {
//Traversing through all the items in the json array
froms.clear();
for (int i = 0; i < j.length(); i++) {
try {
//Getting json object
JSONObject json = j.getJSONObject(i);
//Adding the name of the student to array list
froms.add(json.getString(Configs.TAG_LOCATION));
} catch (JSONException e) {
e.printStackTrace();
}
}
//Setting adapter to show the items in the spinner
travelFrom.setAdapter(new ArrayAdapter<String>(Add_Details_Information.this, android.R.layout.simple_spinner_dropdown_item, froms));
}
For loop is displaying only one item in it which is end of it but i have 2 items in it.shall i have to add the listview?
This is My JSON:
where in subitems i have 2arrays where its displaying 1 array only that too 2 item
this is my JSON:http://www.yell4food.com/json/data_standard_item_new.php?rname=standardtakeaway
Here For loop i have 2items in the subitems but its only displaying the last item in the subitems array:
"menu_name": "Beverages",
"items": [
{
"id": 1,
"BaseName": "Coca-Cola",
"itemdesc": "",
"subitems": [
{
"id": 1,
"SubItemdesc": "0.33L",
"SubItemprice": "0.90"
},
{
"id": 2,
"SubItemdesc": "1.5L",
"SubItemprice": "2.00"
}
]
}
this is My Java Code:
public class Secondlevel extends Activity {
List<JSONParser> itemsdata = new ArrayList<JSONParser>();
String item, ids;
ListView sec;
Second_adapter secondAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.secondlist);
sec = (ListView) findViewById(R.id.seondlst);
// sec.setScrollContainer(false);
secondAdapter = new Second_adapter(Secondlevel.this, itemsdata);
sec.setAdapter(secondAdapter);
Intent hello = getIntent();
item = hello.getStringExtra("name");
loaditems();
}
private void loaditems() {
String Tag = "jsontag";
String url = "http://www.yell4food.com/json/data_standard_item_new.php?rname=standardtakeaway";
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Loading...");
progressDialog.show();
JsonArrayRequest arrayRequest = new JsonArrayRequest(Request.Method.GET, url, (String) null, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
try {
for (int i = 0; i < response.length(); i++) {
JSONObject first = response.getJSONObject(i);
JSONArray getitems = first.getJSONArray("items");
for (int j = 0; j < getitems.length(); j++) {
JSONObject sitems = getitems.getJSONObject(j);
JSONParser parser = new JSONParser();
parser.setIid(sitems.getInt("id"));
parser.setBaseName(sitems.getString("BaseName"));
parser.setItemdesc(sitems.getString("itemdesc"));
JSONArray subitems = sitems.getJSONArray("subitems");
for (int l = 0; l < subitems.length(); l++) {
JSONObject thrid = subitems.getJSONObject(l);
parser.setSid(thrid.getInt("id"));
parser.setSubItemdesc(thrid.getString("SubItemdesc"));
parser.setSubItemprice(thrid.getString("SubItemprice"));
}
itemsdata.add(parser);
}
secondAdapter.notifyDataSetChanged();
}
progressDialog.hide();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("TaG", "Error: " + error);
Toast.makeText(getApplicationContext(),
error.getMessage(), Toast.LENGTH_SHORT).show();
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/json");
params.put("name", item);
return params;
}
};
AppController.getInstance().addToRequestQueue(arrayRequest);
}
}
Try this instead:
try {
for (int i = 0; i < response.length(); i++) {
JSONObject first = response.getJSONObject(i);
JSONArray getitems = first.getJSONArray("items");
for (int j = 0; j < getitems.length(); j++) {
JSONObject sitems = getitems.getJSONObject(j);
JSONArray subitems = sitems.getJSONArray("subitems");
for (int l = 0; l < subitems.length(); l++) {
JSONObject thrid = subitems.getJSONObject(l);
JSONParser parser = new JSONParser();
parser.setIid(sitems.getInt("id"));
parser.setBaseName(sitems.getString("BaseName"));
parser.setItemdesc(sitems.getString("itemdesc"));
parser.setSid(thrid.getInt("id"));
parser.setSubItemdesc(thrid.getString("SubItemdesc"));
parser.setSubItemprice(thrid.getString("SubItemprice"));
itemsdata.add(parser);
}
}
secondAdapter.notifyDataSetChanged();
}
progressDialog.hide();
}