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:com.synox.android.ui.activity.Uploader.java

private void populateDirectoryList() {
    setContentView(R.layout.uploader_layout);

    // Set toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.uploader_toolbar);
    if (toolbar != null) {
        // set toolbar and navigation drawer
        setSupportActionBar(toolbar);//from   w w w.j  a va  2s  . c  o m
    }

    ListView mListView = (ListView) findViewById(android.R.id.list);

    String current_dir = mParents.peek();
    if (current_dir.equals("")) {
        getSupportActionBar().setTitle(getString(R.string.default_display_name_for_root_folder));
    } else {
        getSupportActionBar().setTitle(current_dir);
    }
    getSupportActionBar().setSubtitle(getString(R.string.uploader_top_message));

    boolean notRoot = (mParents.size() > 1);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(notRoot);
    actionBar.setHomeButtonEnabled(notRoot);

    String full_path = generatePath(mParents);

    Log_OC.d(TAG, "Populating view with content of : " + full_path);

    mFile = getStorageManager().getFileByPath(full_path);
    if (mFile != null) {
        // TODO Enable when "On Device" is recovered ?
        Vector<OCFile> files = getStorageManager().getFolderContent(mFile/*, false*/);
        List<HashMap<String, Object>> data = new LinkedList<>();
        for (OCFile f : files) {
            HashMap<String, Object> h = new HashMap<>();
            if (f.isFolder()) {
                h.put("dirname", f.getFileName());
                data.add(h);
            }
        }
        SimpleAdapter sa = new SimpleAdapter(this, data, R.layout.uploader_list_item_layout,
                new String[] { "dirname" }, new int[] { R.id.filename });

        mListView.setAdapter(sa);
        Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder);
        btnChooseFolder.setOnClickListener(this);

        Button btnNewFolder = (Button) findViewById(R.id.uploader_cancel);
        btnNewFolder.setOnClickListener(this);

        mListView.setOnItemClickListener(this);
    }
}

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

@SuppressLint("InlinedApi")
@SuppressWarnings("deprecation")
public void showBrandDialog() {
    if (dataBaseHandler.getBrandsCount() == 0) {
        if (carFunctions.isConnectingToInternet()) {
            new BrandAsyncTask().execute();
        } else {/*  ww  w  .ja  va  2s.c  o  m*/
            Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG).show();
        }

    } else {
        dialog.setContentView(R.layout.add_car_dialog);
        dialog.setCancelable(true);

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

        List<Brand> brandList = dataBaseHandler.getAllBrands();

        carsBrandList.clear();
        for (int i = 0; i < brandList.size(); i++) {
            HashMap<String, String> brand = new HashMap<String, String>();
            brand.put("typeId", brandList.get(i).getTypeId());
            brand.put("typeNameAr", brandList.get(i).getTypeNameAr());
            brand.put("typeNameEn", brandList.get(i).getTypeNameEn());
            brand.put("carModels", brandList.get(i).getCarModels());

            carsBrandList.add(brand);
        }

        ListAdapter adapter = null;

        if (setting.getDuration() == 0) {
            dialog.findViewById(R.id.titleIVAr).setVisibility(View.GONE);
            adapter = new SimpleAdapter(getActivity(), carsBrandList, R.layout.single_brand_item,
                    new String[] { "typeId", "typeNameEn" }, new int[] { R.id.typeId, R.id.typeNameEn });
        } else {
            dialog.findViewById(R.id.titleIVEn).setVisibility(View.GONE);
            dialogTitle.setText(getResources().getString(R.string.add_car_brand_dialog_ar));

            adapter = new SimpleAdapter(getActivity(), carsBrandList, R.layout.single_brand_item,
                    new String[] { "typeId", "typeNameAr" }, new int[] { R.id.typeId, R.id.typeNameEn });
        }

        lv.setAdapter(adapter);

        swipeView = (SwipeRefreshLayout) dialog.findViewById(R.id.swipeDialog);
        swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                swipeView.setRefreshing(true);
                if (carFunctions.isConnectingToInternet()) {
                    new BrandAsyncTask().execute();
                } else {
                    Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG).show();
                }
            }
        });
        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.typeNameEn)).getText().toString();
                brandTV.setText(s);
                String sId = ((TextView) view.findViewById(R.id.typeId)).getText().toString();
                brandIdSelected = sId;

                // Toast.makeText(getActivity(), sId,
                // Toast.LENGTH_SHORT).show();
                brandIdTV.setText(sId);
                dialog.dismiss();
            }
        });

        dialog.show();
    }
}

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

public void dropdownRT() throws JSONException {
    RequestParams params = null;/*from  w  w w  .  j  a v a  2 s.  c om*/
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "RECEIPT_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(ProcessCaseProperty.this, jsonArraylist, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                Receipttype.setAdapter(sAdapPROJ);

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

            } catch (JSONException e) {

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

From source file:com.markupartist.sthlmtraveling.RoutesActivity.java

private void createSections() {
    // Date and time adapter.
    mDateAdapterData = new ArrayList<HashMap<String, String>>(1);
    HashMap<String, String> item = new HashMap<String, String>();
    item.put("title", buildDateString());
    mDateAdapterData.add(item);/*from  w  ww . ja va2  s. c o  m*/
    SimpleAdapter dateTimeAdapter = new SimpleAdapter(this, mDateAdapterData, R.layout.date_and_time,
            new String[] { "title" }, new int[] { R.id.date_time });

    // Earlier routes
    SimpleAdapter earlierAdapter = createEarlierLaterAdapter(R.drawable.arrow_up_float);

    // Later routes
    SimpleAdapter laterAdapter = createEarlierLaterAdapter(R.drawable.arrow_down_float);

    mMultipleListAdapter = new MultipleListAdapter();
    mMultipleListAdapter.addAdapter(ADAPTER_EARLIER, earlierAdapter);
    mMultipleListAdapter.addAdapter(ADAPTER_ROUTES, mRouteAdapter);
    mMultipleListAdapter.addAdapter(ADAPTER_LATER, laterAdapter);

    mSectionedAdapter.addSection(SECTION_CHANGE_TIME, getString(R.string.date_and_time_label), dateTimeAdapter);
    mSectionedAdapter.addSection(SECTION_ROUTES, getString(R.string.route_alternatives_label),
            mMultipleListAdapter);

    setListAdapter(mSectionedAdapter);
    ViewHelper.crossfade(getListView().getEmptyView(), getListView());
}

From source file:net.fred.feedex.activity.EditFeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();/*from   ww  w  . j  a  va2 s  .c  o  m*/
        return true;
    case R.id.menu_validate: // only in insert mode
        final String name = mNameEditText.getText().toString().trim();
        final String urlOrSearch = mUrlEditText.getText().toString().trim();
        if (urlOrSearch.isEmpty()) {
            UiUtils.showMessage(EditFeedActivity.this, R.string.error_feed_error);
        }

        if (!urlOrSearch.contains(".") || !urlOrSearch.contains("/") || urlOrSearch.contains(" ")) {
            final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
            pd.setMessage(getString(R.string.loading));
            pd.setCancelable(true);
            pd.setIndeterminate(true);
            pd.show();

            getLoaderManager().restartLoader(1, null,
                    new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                        @Override
                        public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) {
                            String encodedSearchText = urlOrSearch;
                            try {
                                encodedSearchText = URLEncoder.encode(urlOrSearch, Constants.UTF8);
                            } catch (UnsupportedEncodingException ignored) {
                            }

                            return new GetFeedSearchResultsLoader(EditFeedActivity.this, encodedSearchText);
                        }

                        @Override
                        public void onLoadFinished(Loader<ArrayList<HashMap<String, String>>> loader,
                                final ArrayList<HashMap<String, String>> data) {
                            pd.cancel();

                            if (data == null) {
                                UiUtils.showMessage(EditFeedActivity.this, R.string.error);
                            } else if (data.isEmpty()) {
                                UiUtils.showMessage(EditFeedActivity.this, R.string.no_result);
                            } else {
                                AlertDialog.Builder builder = new AlertDialog.Builder(EditFeedActivity.this);
                                builder.setTitle(R.string.feed_search);

                                // create the grid item mapping
                                String[] from = new String[] { FEED_SEARCH_TITLE, FEED_SEARCH_DESC };
                                int[] to = new int[] { android.R.id.text1, android.R.id.text2 };

                                // fill in the grid_item layout
                                SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this, data,
                                        R.layout.item_search_result, from, to);
                                builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        FeedDataContentProvider.addFeed(EditFeedActivity.this,
                                                data.get(which).get(FEED_SEARCH_URL),
                                                name.isEmpty() ? data.get(which).get(FEED_SEARCH_TITLE) : name,
                                                mRetrieveFulltextCb.isChecked());

                                        setResult(RESULT_OK);
                                        finish();
                                    }
                                });
                                builder.show();
                            }
                        }

                        @Override
                        public void onLoaderReset(Loader<ArrayList<HashMap<String, String>>> loader) {
                        }
                    });
        } else {
            FeedDataContentProvider.addFeed(EditFeedActivity.this, urlOrSearch, name,
                    mRetrieveFulltextCb.isChecked());

            setResult(RESULT_OK);
            finish();
        }
        return true;
    case R.id.menu_add_filter: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null);

        new AlertDialog.Builder(this) //
                .setTitle(R.string.filter_add_title) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText()
                                .toString();
                        if (filterText.length() != 0) {
                            String feedId = getIntent().getData().getLastPathSegment();

                            ContentValues values = new ContentValues();
                            values.put(FilterColumns.FILTER_TEXT, filterText);
                            values.put(FilterColumns.IS_REGEX,
                                    ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked());
                            values.put(FilterColumns.IS_APPLIED_TO_TITLE,
                                    ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked());
                            values.put(FilterColumns.IS_ACCEPT_RULE,
                                    ((RadioButton) dialogView.findViewById(R.id.acceptRadio)).isChecked());

                            ContentResolver cr = getContentResolver();
                            cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values);
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                }).show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

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

public void dropdowntype1() throws JSONException {
    RequestParams params = null;/* w ww .  j a  v  a  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_TYPE_SPINNER, 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(ProcessCaseVendor.this, jsonArraylist, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                // All adapters has been set here
                spinner_type1.setAdapter(sAdapPROJ);
                spinner_type2.setAdapter(sAdapPROJ);
                spinner_type3.setAdapter(sAdapPROJ);
                spinner_type4.setAdapter(sAdapPROJ);

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

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

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

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

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

            } catch (JSONException e) {

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

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

public void dropdownf1() throws JSONException {
    RequestParams params = null;/*  w ww .  j  a v a  2 s .  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 });

                sf1.setAdapter(sAdapPROJ);
                sf2.setAdapter(sAdapPROJ);
                sf3.setAdapter(sAdapPROJ);
                sf4.setAdapter(sAdapPROJ);
                sf5.setAdapter(sAdapPROJ);

                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Ssf1)) {
                        sf1.setSelection(j);
                        break;
                    }
                }
                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Ssf2)) {
                        sf2.setSelection(j);
                        break;
                    }
                }
                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Ssf3)) {
                        sf3.setSelection(j);
                        break;
                    }
                }
                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Ssf4)) {
                        sf4.setSelection(j);
                        break;
                    }
                }
                for (int j = 0; j < jsonArraylist.size(); j++) {
                    if (jsonArraylist.get(j).get("Id_T").equals(Ssf5)) {
                        sf5.setSelection(j);
                        break;
                    }
                }

            } catch (JSONException e) {

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

From source file:com.slp.rss_api.activity.EditFeedActivity.java

public void onClickOk(View view) {
    // only in insert mode

    final String name = mNameEditText.getText().toString().trim();
    final String urlOrSearch = mUrlEditText.getText().toString().trim();
    if (urlOrSearch.isEmpty()) {
        Toast.makeText(this, R.string.error_feed_error, Toast.LENGTH_SHORT).show();
    }/*from   ww  w  .  j a va  2s  . co  m*/

    if (!urlOrSearch.contains(".") || !urlOrSearch.contains("/") || urlOrSearch.contains(" ")) {
        final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
        pd.setMessage(getString(R.string.loading));
        pd.setCancelable(true);
        pd.setIndeterminate(true);
        pd.show();

        getLoaderManager().restartLoader(1, null,
                new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                    @Override
                    public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) {
                        String encodedSearchText = urlOrSearch;
                        try {
                            encodedSearchText = URLEncoder.encode(urlOrSearch, Constants.UTF8);
                        } catch (UnsupportedEncodingException ignored) {
                        }

                        return new GetFeedSearchResultsLoader(EditFeedActivity.this, encodedSearchText);
                    }

                    @Override
                    public void onLoadFinished(Loader<ArrayList<HashMap<String, String>>> loader,
                            final ArrayList<HashMap<String, String>> data) {
                        pd.cancel();

                        if (data == null) {
                            Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show();
                        } else if (data.isEmpty()) {
                            Toast.makeText(EditFeedActivity.this, R.string.no_result, Toast.LENGTH_SHORT)
                                    .show();
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(EditFeedActivity.this);
                            builder.setTitle(R.string.feed_search);

                            // create the grid item mapping
                            String[] from = new String[] { FEED_SEARCH_TITLE, FEED_SEARCH_DESC };
                            int[] to = new int[] { android.R.id.text1, android.R.id.text2 };

                            // fill in the grid_item layout
                            SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this, data,
                                    R.layout.item_search_result, from, to);
                            builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    FeedDataContentProvider.addFeed(EditFeedActivity.this,
                                            data.get(which).get(FEED_SEARCH_URL),
                                            name.isEmpty() ? data.get(which).get(FEED_SEARCH_TITLE) : name,
                                            mRetrieveFulltextCb.isChecked());

                                    setResult(RESULT_OK);
                                    finish();
                                }
                            });
                            builder.show();
                        }
                    }

                    @Override
                    public void onLoaderReset(Loader<ArrayList<HashMap<String, String>>> loader) {
                    }
                });
    } else {
        FeedDataContentProvider.addFeed(EditFeedActivity.this, urlOrSearch, name,
                mRetrieveFulltextCb.isChecked());

        setResult(RESULT_OK);
        finish();
    }
}

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

public void Subtype() throws JSONException {
    RequestParams params = null;//from   w  w w  .  j av a  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("SPA_ProcessCase_TitleSubType", 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 });

                Subtype.setAdapter(sAdapPROJ);

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

            } catch (JSONException e) {

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

From source file:com.markupartist.sthlmtraveling.RoutesActivity.java

/**
 * Helper to create earlier or later adapter.
 * @param resource the image resource to show in the list
 * @return a prepared adapter//  ww w .jav  a  2  s  .  c o  m
 */
private SimpleAdapter createEarlierLaterAdapter(int resource) {
    ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("image", resource);
    list.add(map);

    SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.earlier_later_routes_row,
            new String[] { "image" }, new int[] { R.id.earlier_later, });

    adapter.setViewBinder(new ViewBinder() {
        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            switch (view.getId()) {
            case R.id.earlier_later:
                ImageView imageView = (ImageView) view;
                imageView.setImageResource((Integer) data);
                return true;
            }
            return false;
        }
    });
    return adapter;
}