Note that there are some explanatory texts on larger screens.

plurals
  1. PODelete particular value from Spinner in Android
    primarykey
    data
    text
    <p>I have to parse data from server to spinner. Now I want to delete some value from Spinner . </p> <p>Here is my code .</p> <p>mytaxList include all values. Now I want put check that if TaxType is compound delete TaxName and TaxValue of that type from spinner. Actually i donot want to display cound type tax in spinner. i.e i want to remove compound type tax from ArrayList mytaxList.</p> <pre><code>JSONObject taxes = returnTaxlist.getJSONObject(TAG_TAXES); Object tax ; if (taxes.optJSONArray("tax") != null){ //The result isn't null so it is a JSONArray tax = taxes.optJSONArray("tax"); } else { //The result is null so it isn't a JSONArray tax = taxes.optJSONObject("tax"); } if (tax instanceof JSONObject){ // The object is a JSONObject tax = taxes.getJSONObject(TAG_TAX); } else { // The object is a JSONArray tax = taxes.getJSONArray(TAG_TAX); mytaxList = new ArrayList&lt;TaxList&gt;(); for(int i = 0; i &lt;=((JSONArray)tax).length(); i++) { if(i==0){ TaxList iTaxClass = new TaxList(); iTaxClass.setTaxId(""); iTaxClass.setTaxName("--Select--"); iTaxClass.setTaxType(""); iTaxClass.setTaxvalue(""); mytaxList.add(iTaxClass); continue; } JSONObject taxlist = ((JSONArray)tax).getJSONObject(i-1); TaxList iTaxClass = new TaxList(); //***** Storing each JSON item in variable iTaxClass.setTaxId(taxlist.getString(TAG_TAX_ID)); iTaxClass.setTaxName(taxlist.getString(TAG_TAX_NAME)); iTaxClass.setTaxType(taxlist.getString(TAG_TAX_TYPE)); iTaxClass.setTaxvalue(taxlist.getString(TAG_TAX_VALUE)); mytaxList.add(iTaxClass); } tax1 = (Spinner)findViewById(R.id.item1); tax1.setAdapter(new TaxListAdapter(mytaxList,this)); tax1.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { public void onItemSelected(AdapterView&lt;?&gt; parent, View selectedItemView, int position, long id) { TaxListAdapter taxlistvalue = (TaxListAdapter)parent.getAdapter(); taxlistvalue.getItemId(position); } public void onNothingSelected(AdapterView&lt;?&gt; arg0) { } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload