Dialog List menu

int[] menu_image_array = { R.drawable.ic_attach_picture,
            R.drawable.ic_attach_capture_photo, R.drawable.ic_attach_audio,
            R.drawable.ic_attach_capture_audio, R.drawable.ic_attach_vcard};

    int[] menu_name_array = { R.string.attach_image, R.string.attach_take_photo,
            R.string.attach_sound, R.string.attach_record_sound,
            R.string.attach_add_contact_as_vcard};


    public void showAttachSelectorList() {
        runOnUiThread(new Runnable() {
            public void run() {
                View menuView = getLayoutInflater().inflate(R.layout.selector_attachment_list, null);
                AlertDialog.Builder builder = new AlertDialog.Builder(ComposeMessageActivity.this);
                builder.setView(menuView);
                ListView seletorList = (ListView) menuView.findViewById(R.id.selectList);
                seletorList.setAdapter(getMenuAdapter(menu_name_array, menu_image_array));
             }
         });
    }

        private SimpleAdapter getMenuAdapter(int[] menuNameArray,
            int[] imageResourceArray) {
        ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
        for (int i = 0; i < menuNameArray.length; i++) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("itemImage", imageResourceArray[i]);
            map.put("itemText", menuNameArray[i]);
            data.add(map);
        }

        SimpleAdapter simperAdapter = new SimpleAdapter(this, data,
                R.layout.selector_list_item, new String[] { "itemImage", "itemText" },
                new int[] { R.id.icon, R.id.text });
        return simperAdapter;
    }

results matching ""

    No results matching ""