Example usage for android.widget SimpleAdapter SimpleAdapter

List of usage examples for android.widget SimpleAdapter SimpleAdapter

Introduction

In this page you can find the example usage for android.widget SimpleAdapter SimpleAdapter.

Prototype

public SimpleAdapter(Context context, List<? extends Map<String, ?>> data, @LayoutRes int resource,
        String[] from, @IdRes int[] to) 

Source Link

Document

Constructor

Usage

From source file:smart.services.fragment.AddCar.java

@SuppressLint("InlinedApi")
@SuppressWarnings("deprecation")
public void showModelDialog() {
    dialog.setContentView(R.layout.add_car_dialog);
    dialog.setCancelable(true);/*  w  ww.ja va  2  s .  c  om*/

    TextView dialogTitleTV = (TextView) dialog.findViewById(R.id.brandsListTitleTV);

    Booking.changeWidthHeight(getActivity(), dialog);
    // dialog.setP
    lv = (ListView) dialog.findViewById(R.id.addLV);

    if (dataBaseHandler.getModelsCount() == 0) {
        if (carFunctions.isConnectingToInternet()) {
            new CarModel().execute();
        } else {
            Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG).show();
        }
    } else {
        List<Model> modelList = dataBaseHandler.getAllModels();
        carsModelList.clear();
        for (int i = 0; i < modelList.size(); i++) {
            if (modelList.get(i).getParentBrand().equals(brandTV.getText().toString()) || modelList.get(i)
                    .getParentBrand().equals(dataBaseHandler.getBrand(brandIdSelected).getTypeNameEn())) {
                HashMap<String, String> model = new HashMap<String, String>();

                model.put("modelId", modelList.get(i).getTypeId());
                model.put("modelNameAr", modelList.get(i).getTypeNameAr());
                model.put("modelNameEn", modelList.get(i).getTypeNameEn());

                carsModelList.add(model);
            }
        }

        if (carsModelList.size() == 0) {
            if (carFunctions.isConnectingToInternet()) {
                for (int i = 0; i < modelList.size(); i++) {
                    if (modelList.get(i).getParentBrand().equals(brandTV.getText().toString())
                            || modelList.get(i).getParentBrand()
                                    .equals(dataBaseHandler.getBrand(brandIdSelected).getTypeNameEn())) {
                        dataBaseHandler.deleteSingleBrand(modelList.get(i).getId());
                    }
                }
                new CarModel().execute();
            } else {
                Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG).show();
            }
        } else {
            ListAdapter adapter = null;
            if (setting.getDuration() == 0) {
                dialog.findViewById(R.id.titleIVAr).setVisibility(View.GONE);
                dialogTitleTV.setText(getResources().getString(R.string.model_list_en));

                adapter = new SimpleAdapter(getActivity(), carsModelList, R.layout.single_model_item,
                        new String[] { "modelId", "modelNameEn" },
                        new int[] { R.id.modelId, R.id.modelNameEn });
            } else {
                dialog.findViewById(R.id.titleIVEn).setVisibility(View.GONE);
                dialogTitleTV.setText(getResources().getString(R.string.model_list_ar));

                adapter = new SimpleAdapter(getActivity(), carsModelList, R.layout.single_model_item,
                        new String[] { "modelId", "modelNameAr" },
                        new int[] { R.id.modelId, R.id.modelNameEn });
            }

            lv.setAdapter(adapter);
            dialog.show();
        }

    }
    swipeView = (SwipeRefreshLayout) dialog.findViewById(R.id.swipeDialog);
    swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeView.setRefreshing(true);
            if (carFunctions.isConnectingToInternet()) {
                // new CarModel().execute();
            } else {
                Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG).show();
            }
            swipeView.setRefreshing(false);
        }
    });
    swipeView.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
            android.R.color.holo_orange_light, android.R.color.holo_red_light);

    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String s = ((TextView) view.findViewById(R.id.modelNameEn)).getText().toString();
            modelTV.setText(s);
            String sId = ((TextView) view.findViewById(R.id.modelId)).getText().toString();
            // modelTV.setText(s);
            modelIdTV.setText(sId);
            dialog.dismiss();
        }
    });

}

From source file:com.fitforbusiness.nafc.dashboard.DashBoardFragment.java

private void setBusinessAlerts() {

    ArrayList<Map<String, String>> mapArrayList = new ArrayList<Map<String, String>>();
    SQLiteDatabase sqlDB = null;/*from   w  ww  . j  av a2 s.c o  m*/
    try {
        sqlDB = DatabaseHelper.instance().getReadableDatabase();

        String query = "select julianday(pt_license_renewal_date)-julianday('now')  as pt_license, "
                + " julianday(first_aid_cert_renewal_date)-julianday('now')  as first_aid, "
                + " julianday(cpr_cert_renewal_date)-julianday('now')  as cpr_cert, "
                + " julianday(aed_cert_renewal_date)-julianday('now')  as aed_cert from trainer";

        Log.d("query is ", query);
        Cursor cursor = sqlDB.rawQuery(query, null);

        LinkedHashMap<String, String> row;
        if (cursor.moveToFirst()) {
            if (cursor.getFloat(cursor.getColumnIndex("pt_license")) < 90) {
                row = new LinkedHashMap<String, String>();
                if (cursor.getFloat(cursor.getColumnIndex("pt_license")) < 0) {
                    row.put("title", "PT License is overdue.");
                } else {
                    row.put("title", "PT License is due for renewal.");
                }

                row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("pt_license")) + " day");
                mapArrayList.add(row);
            }
            if (cursor.getFloat(cursor.getColumnIndex("first_aid")) < 90) {
                row = new LinkedHashMap<String, String>();
                if (cursor.getFloat(cursor.getColumnIndex("first_aid")) < 0) {
                    row.put("title", "First Aid is overdue.");
                } else {
                    row.put("title", "First Aid is due for renewal.");
                }

                row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("first_aid")) + " day");
                mapArrayList.add(row);
            }
            if (cursor.getFloat(cursor.getColumnIndex("cpr_cert")) < 90) {
                row = new LinkedHashMap<String, String>();
                if (cursor.getFloat(cursor.getColumnIndex("cpr_cert")) < 0) {
                    row.put("title", "CPR Certificate is overdue.");
                } else {
                    row.put("title", "CPR Certificate is due for renewal.");
                }

                row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("cpr_cert")) + " day");
                mapArrayList.add(row);
            }
            if (cursor.getFloat(cursor.getColumnIndex("aed_cert")) < 90) {
                row = new LinkedHashMap<String, String>();
                if (cursor.getFloat(cursor.getColumnIndex("aed_cert")) < 0) {
                    row.put("title", "AED Certificate is overdue.");
                } else {
                    row.put("title", "AED Certificate is due for renewal.");
                }
                row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("aed_cert")) + " day");
                mapArrayList.add(row);
            }

        }
        cursor.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
    }
    adapter = new SimpleAdapter(getActivity(), mapArrayList, R.layout.custom_list_row_assesssment,
            new String[] { "title", "no_of_days" }, new int[] { R.id.tvFormName, R.id.tvNoOfFields });

}

From source file:smart.services.adapter.ManageCarsAdapter.java

public void showColorDialog() {
    dialog.setContentView(R.layout.add_car_dialog);
    dialog.setCancelable(true);/* www . j a v a 2 s  .c o  m*/
    dialog.setTitle("Choose a Color");
    Booking.changeWidthHeight(context, dialog);
    // dialog.setP
    lv = (ListView) dialog.findViewById(R.id.addLV);

    if (dataBaseHandler.getColorsCount() == 0) {
        if (isConnectingToInternet()) {
            new CarColor().execute();
        } else {
            Toast.makeText(context, "Check your internet connection", Toast.LENGTH_LONG).show();
        }
    } else {
        List<Color> colorList = dataBaseHandler.getAllColors();

        carsColorList.clear();
        for (int i = 0; i < colorList.size(); i++) {
            HashMap<String, String> color = new HashMap<String, String>();
            color.put("id", colorList.get(i).getColorId());
            color.put("coloAr", colorList.get(i).getColorAr());
            color.put("colorEn", colorList.get(i).getColorEn());

            carsColorList.add(color);
        }
        ListAdapter adapter = new SimpleAdapter(context, carsColorList, R.layout.single_color_item,
                new String[] { "id", "colorEn" }, new int[] { R.id.id, R.id.colorEn });

        lv.setAdapter(adapter);

        lv.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                finalColorId = carsColorList.get(position).get("id");
                String colorEn = ((TextView) view.findViewById(R.id.colorEn)).getText().toString();
                String idC = ((TextView) view.findViewById(R.id.id)).getText().toString();
                colorNameTV.setText(colorEn);
                colorIdTV.setText(idC);
                dialog.dismiss();
            }
        });

        dialog.show();
    }
}

From source file:com.abeo.tia.noordin.ProcessCaseProperty.java

public void dropdownKIV() throws JSONException {
    RequestParams params = null;/*  w  w  w .j  a  va  2  s . c o  m*/
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "KIVSTATUS");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("Failed");

        }

        @Override
        protected String parseResponse(String s, boolean b) throws Throwable {
            return null;
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Title Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonArraylist = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonArraylist.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonArraylist);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(ProcessCaseProperty.this, jsonArraylist, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinner_kiv.setAdapter(sAdapPROJ);

                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Skiv)) {
                        spinner_kiv.setSelection(j);
                        break;
                    }
                }

            } catch (JSONException e) {

                e.printStackTrace();
            }
        }
    });
}

From source file:com.abeo.tia.noordin.ProcesscaseLoanSubsidiary.java

public void dropdownf3() throws JSONException {
    RequestParams params = null;//from www .j a va 2s  .c  o m
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "LOAN_PRNCP_TYPE");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("Failed");

        }

        @Override
        protected String parseResponse(String s, boolean b) throws Throwable {
            return null;
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Title Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonArraylist = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonArraylist.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonArraylist);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(ProcesscaseLoanSubsidiary.this, jsonArraylist,
                        R.layout.spinner_item, new String[] { "Id_T", "Name_T" },
                        new int[] { R.id.Id, R.id.Name });

                sf3.setAdapter(sAdapPROJ);

                /*for (int j = 0; j < jsonlistProject.size(); j++) {
                        if (jsonlistProject.get(j).get("Id_T").equals(projectDetailResponse)) {
                      TitleType_DROPDOWN.setSelection(j);
                      break;
                   }
                }*/

            } catch (JSONException e) {

                e.printStackTrace();
            }
        }
    });
}

From source file:com.abeo.tia.noordin.ProcessCaseLoanPrincipal.java

public void dropdownBankDeveloperSolicitor() {

    RequestParams params = null;/* ww w  . j  a  v a  2s . co  m*/
    params = new RequestParams();

    RestService.post("SPA_Property_GetDropdownValues", params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Property Activity GetDropdown Success Details ");
            try {
                // Create new list
                jsonlistBank = new ArrayList<HashMap<String, String>>();

                jsonResponse = new JSONObject(arg2);

                JSONArray jsonBank = jsonResponse.getJSONArray("Bank");
                for (int j = 0; j < jsonBank.length(); j++) {
                    JSONObject bank = jsonBank.getJSONObject(j);

                    id_b = bank.getString("BankCode").toString();
                    name_b = bank.getString("BankName").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> bankList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON BANK LIST");
                    bankList.put("Id_T", id_b);
                    System.out.println(name);
                    bankList.put("Name_T", name_b);
                    System.out.println(name);
                    System.out.println(" END SEND JSON BANK LIST");

                    jsonlistBank.add(bankList);
                    System.out.println("JSON BANK LIST");
                    //System.out.println(jsonlistProject);

                }

                // Spinner set Array Data in Drop down

                sAdapBANK = new SimpleAdapter(ProcessCaseLoanPrincipal.this, jsonlistBank,
                        R.layout.spinner_item, new String[] { "Id_T", "Name_T" },
                        new int[] { R.id.Id, R.id.Name });

                spinnerpropertyLSTCHG_BANKNAME.setAdapter(sAdapBANK);

                for (int j = 0; j < jsonlistBank.size(); j++) {
                    if (jsonlistBank.get(j).get("Name_T").equals(master_bankname)) {
                        spinnerpropertyLSTCHG_BANKNAME.setSelection(j);
                        break;
                    }
                }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            System.out.println(arg2);

        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {
            // Get Json response

            System.out.println("Property GetDropdown parse Response");
            System.out.println(arg0);
            return null;
        }

    });

}

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

public void addCaseListOfItems() {

    RequestParams params = null;/*from w  ww  .  jav a2s  .c  o  m*/
    params = new RequestParams();

    RestService.post(METHOD_ADDCASE_ITEMLIST, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Add Case List Item Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonItemList = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    itemCode = jsonResponse.getString("ItemCode").toString();
                    itemName = jsonResponse.getString("ItemName").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> addCaseItemList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND ADD CASE ITEM LIST");
                    addCaseItemList.put("ItemCode_T", itemCode);
                    System.out.println(itemCode);
                    addCaseItemList.put("ItemName_T", itemName);
                    System.out.println(itemName);
                    System.out.println(" END ADD CASE ITEM LIST");

                    jsonItemList.add(addCaseItemList);
                    System.out.println("JSON ADD CASE ITEM LIST");
                    System.out.println(jsonItemList);
                }

            } catch (JSONException e) { // TODO Auto-generated
                // catch
                // block
                e.printStackTrace();
            }
            //Toast.makeText(AddCaseStep2of4.this, "AddCase Item Found", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
            // Simple Adapter for List
            SimpleAdapter simpleAdapter = new SimpleAdapter(AddCaseStep2of4.this, jsonItemList,
                    R.layout.listview_column_addcase_itemlist, new String[] { "ItemCode_T", "ItemName_T" },
                    new int[] { R.id.listAddCaseHeader_ItemCodeText, R.id.listAddCaseHeader_ItemNameText });

            listViewItem.setAdapter(simpleAdapter);

            listViewItem.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                View ls = null;

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    if (get() != view && get() != null) {
                        get().setActivated(false);
                    }
                    //Toast.makeText(AddCaseStep2of4.this, "You Clicked at " + jsonItemList.get(position),
                    //   Toast.LENGTH_SHORT).show();
                    System.out.println(position);

                    //int mSelectedItem = position;      

                    view.setActivated(true);

                    // Get list of Item data
                    TextView c = (TextView) view.findViewById(R.id.listAddCaseHeader_ItemCodeText);
                    itemCode = c.getText().toString();
                    System.out.println(itemCode);

                    TextView D = (TextView) view.findViewById(R.id.listAddCaseHeader_ItemNameText);
                    itemName = D.getText().toString();

                    String data = (String) parent.getItemAtPosition(position).toString();
                    System.out.println(data);
                    set(view);

                    //store itemname and code in session
                    SharedPreferences prefLogin = getSharedPreferences("ItemData", Context.MODE_PRIVATE);

                    // We need an editor object to make changes
                    SharedPreferences.Editor edit = prefLogin.edit();

                    // Set/Store data
                    edit.putString("ItemCode", itemCode);
                    edit.putString("ItemName", itemName);
                    // Commit the changes
                    edit.commit();

                }

                private void set(View view) {
                    ls = view;
                }

                private View get() {
                    return ls;
                }
            });

            spinnerpropertyPROJECT.setSelection(2);
        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("Add Case List Itemparse ParseResponse");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:com.aslanoba.hwc.SettingsActivity.java

/**
 * Reload list control from existing settings list.
 *///  w w  w. j  a v a2s.c om
public void refreshList() {
    // Filter the settings list to only include the settings the customer wants
    // to show.
    m_filteredSettings = new Vector<SettingsListItem>();
    for (int i = 0; i < m_lstSettings.size(); i++) {
        SettingsListItem oItem = m_lstSettings.get(i);

        switch (oItem.m_iPropId) {
        case PropertyID.CONNECTION_AUTO_REGISTRATION_HINT:
            if (CustomizationHelper.getInstance().isConnectionRegistrationMethodVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.CONNECTION_SERVER_NAME:
            if (CustomizationHelper.getInstance().isConnectionServerNameVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.CONNECTION_USER_NAME:
            if (CustomizationHelper.getInstance().isConnectionUserNameVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.CONNECTION_SERVER_PORT:
            if (CustomizationHelper.getInstance().isConnectionServerPortVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.CONNECTION_ACTIVATION_CODE:
            if (CustomizationHelper.getInstance().isConnectionActivationCodeVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.CONNECTION_FARM_ID:
            if (CustomizationHelper.getInstance().isConnectionFarmIdVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.ADVANCED_RELAY_SVR_URL_TEMPLATE:
            if (CustomizationHelper.getInstance().isConnectionUrlSuffixVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.CONNECTION_PASSWORD:
            if (CustomizationHelper.getInstance().isConnectionPasswordVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        case PropertyID.CONNECTION_USE_HTTPS:
            if (CustomizationHelper.getInstance().isConnectionHTTPSVisible()) {
                m_filteredSettings.add(oItem);
            }
            break;
        }
    }

    // Create placeholders in adapter data structure so it knows how many items
    // to display.  We will fill in the actual display data in getView() based on the
    // position
    ArrayList<HashMap<String, String>> lst = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < m_filteredSettings.size(); i++)
        lst.add(new HashMap<String, String>());

    // While we are setting a list adapter, we are only using it to hold the
    // structure of the list.  We will actually override its data in getView()
    // before displaying it.
    setListAdapter(new SimpleAdapter(this, lst, R.layout.settings_row, new String[] { "text1", "text2" },
            new int[] { android.R.id.text1, android.R.id.text2 }) {
        /**
        * Override for the getView() method.  This allows us to alter the display
        * attributes on a line-by-line basis.  We also use this opportunity to
        * fill in the text fields with the right values.
        */
        @Override
        public View getView(int iPos, View oConvertView, ViewGroup oParent) {
            SettingsListItem oItem = m_filteredSettings.get(iPos);
            setItemState(oItem);

            // create view for this row from xml layout file
            View oView = m_oInflater.inflate(R.layout.settings_row, null);

            // for some reason, the logic in this method call seems to be reversed,
            // but it works this way
            oView.setClickable(oItem.m_bLocked);

            // set up the label text view
            TextView tvLabel = (TextView) oView.findViewById(android.R.id.text1);
            if (tvLabel != null) {
                tvLabel.setText(getItemLabel(oItem));
                tvLabel.setEnabled(!oItem.m_bLocked);
            }

            // set up the value text view
            TextView tvValue = (TextView) oView.findViewById(android.R.id.text2);
            if (tvValue != null) {
                String sValue = oItem.getDisplayText();

                if (oItem.m_bPassword)
                    tvValue.setText(sValue.length() > 0 ? "******" : "");
                else
                    tvValue.setText(sValue);

                tvValue.setEnabled(!oItem.m_bLocked);
                // Please note that attempting to setInputType here to mask the password value crashes
                // HTC desire HD device. To avoid that we are working around by displaying asterix in
                // password field.

            }

            return oView;
        }
    });
}

From source file:com.abeo.tia.noordin.ProcessCaseProperty.java

public void dropdownstatus() throws JSONException {
    RequestParams params = null;//from   ww  w. ja v  a 2s .  com
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "CASESTATUS");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("Failed");

        }

        @Override
        protected String parseResponse(String s, boolean b) throws Throwable {
            return null;
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Title Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonArraylist = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonArraylist.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonArraylist);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(ProcessCaseProperty.this, jsonArraylist, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinner_case_status.setAdapter(sAdapPROJ);

                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Scase_status)) {
                        spinner_case_status.setSelection(j);
                        break;
                    }
                }

            } catch (JSONException e) {

                e.printStackTrace();
            }
        }
    });
}

From source file:com.abeo.tia.noordin.ProcesscaseLoanSubsidiary.java

public void dropdownf4() throws JSONException {
    RequestParams params = null;//w ww .j a va 2s.  c o m
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "LOAN_PRNCP_TYPE");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("Failed");

        }

        @Override
        protected String parseResponse(String s, boolean b) throws Throwable {
            return null;
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Title Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonArraylist = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonArraylist.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonArraylist);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(ProcesscaseLoanSubsidiary.this, jsonArraylist,
                        R.layout.spinner_item, new String[] { "Id_T", "Name_T" },
                        new int[] { R.id.Id, R.id.Name });

                sf4.setAdapter(sAdapPROJ);

                /*for (int j = 0; j < jsonlistProject.size(); j++) {
                        if (jsonlistProject.get(j).get("Id_T").equals(projectDetailResponse)) {
                      TitleType_DROPDOWN.setSelection(j);
                      break;
                   }
                }*/

            } catch (JSONException e) {

                e.printStackTrace();
            }
        }
    });
}