Example usage for android.widget ListView setDividerHeight

List of usage examples for android.widget ListView setDividerHeight

Introduction

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

Prototype

public void setDividerHeight(int height) 

Source Link

Document

Sets the height of the divider that will be drawn between each item in the list.

Usage

From source file:org.telegram.ui.ChannelUsersActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (type == 0) {
        actionBar.setTitle(LocaleController.getString("ChannelBlockedUsers", R.string.ChannelBlockedUsers));
    } else if (type == 1) {
        actionBar.setTitle(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators));
    } else if (type == 2) {
        actionBar.setTitle(LocaleController.getString("ChannelMembers", R.string.ChannelMembers));
    }/*from  w  w w  . j  ava  2s.c o  m*/
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();

    fragmentView = new FrameLayout(context);
    fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));
    FrameLayout frameLayout = (FrameLayout) fragmentView;

    emptyView = new EmptyTextProgressView(context);
    if (type == 0) {
        if (isMegagroup) {
            emptyView.setText(LocaleController.getString("NoBlockedGroup", R.string.NoBlockedGroup));
        } else {
            emptyView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
        }
    }
    frameLayout.addView(emptyView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    final ListView listView = new ListView(context);
    listView.setEmptyView(emptyView);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setDrawSelectorOnTop(true);
    listView.setAdapter(listViewAdapter = new ListAdapter(context));
    listView.setVerticalScrollbarPosition(
            LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (type == 2) {
                if (isAdmin) {
                    if (i == 0) {
                        Bundle args = new Bundle();
                        args.putBoolean("onlyUsers", true);
                        args.putBoolean("destroyAfterSelect", true);
                        args.putBoolean("returnAsResult", true);
                        args.putBoolean("needForwardCount", false);
                        args.putBoolean("allowUsernameSearch", false);
                        args.putString("selectAlertString",
                                LocaleController.getString("ChannelAddTo", R.string.ChannelAddTo));
                        ContactsActivity fragment = new ContactsActivity(args);
                        fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() {
                            @Override
                            public void didSelectContact(TLRPC.User user, String param) {
                                MessagesController.getInstance().addUserToChat(chatId, user, null,
                                        param != null ? Utilities.parseInt(param) : 0, null,
                                        ChannelUsersActivity.this);
                            }
                        });
                        presentFragment(fragment);
                    } else if (!isPublic && i == 1) {
                        presentFragment(new GroupInviteActivity(chatId));
                    }
                }

            } else if (type == 1) {
                if (isAdmin) {
                    if (isMegagroup && (i == 1 || i == 2)) {
                        TLRPC.Chat chat = MessagesController.getInstance().getChat(chatId);
                        if (chat == null) {
                            return;
                        }
                        boolean changed = false;
                        if (i == 1 && !chat.democracy) {
                            chat.democracy = true;
                            changed = true;
                        } else if (i == 2 && chat.democracy) {
                            chat.democracy = false;
                            changed = true;
                        }
                        if (changed) {
                            MessagesController.getInstance().toogleChannelInvites(chatId, chat.democracy);
                            int count = listView.getChildCount();
                            for (int a = 0; a < count; a++) {
                                View child = listView.getChildAt(a);
                                if (child instanceof RadioCell) {
                                    int num = (Integer) child.getTag();
                                    ((RadioCell) child).setChecked(
                                            num == 0 && chat.democracy || num == 1 && !chat.democracy, true);
                                }
                            }
                        }
                        return;
                    }
                    if (i == participantsStartRow + participants.size()) {
                        Bundle args = new Bundle();
                        args.putBoolean("onlyUsers", true);
                        args.putBoolean("destroyAfterSelect", true);
                        args.putBoolean("returnAsResult", true);
                        args.putBoolean("needForwardCount", false);
                        args.putBoolean("allowUsernameSearch", true);
                        /*if (isMegagroup) {
                        args.putBoolean("allowBots", false);
                        }*/
                        args.putString("selectAlertString", LocaleController
                                .getString("ChannelAddUserAdminAlert", R.string.ChannelAddUserAdminAlert));
                        ContactsActivity fragment = new ContactsActivity(args);
                        fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() {
                            @Override
                            public void didSelectContact(TLRPC.User user, String param) {
                                setUserChannelRole(user, new TLRPC.TL_channelRoleEditor());
                            }
                        });
                        presentFragment(fragment);
                        return;
                    }
                }
            }
            TLRPC.ChannelParticipant participant = null;
            if (i >= participantsStartRow && i < participants.size() + participantsStartRow) {
                participant = participants.get(i - participantsStartRow);
            }
            if (participant != null) {
                Bundle args = new Bundle();
                args.putInt("user_id", participant.user_id);
                presentFragment(new ProfileActivity(args));
            }
        }
    });

    if (isAdmin || isMegagroup && type == 0) {
        listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
                if (getParentActivity() == null) {
                    return false;
                }
                TLRPC.ChannelParticipant participant = null;
                if (i >= participantsStartRow && i < participants.size() + participantsStartRow) {
                    participant = participants.get(i - participantsStartRow);
                }
                if (participant != null) {
                    final TLRPC.ChannelParticipant finalParticipant = participant;
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    CharSequence[] items = null;
                    if (type == 0) {
                        items = new CharSequence[] { LocaleController.getString("Unblock", R.string.Unblock) };
                    } else if (type == 1) {
                        items = new CharSequence[] { LocaleController.getString("ChannelRemoveUserAdmin",
                                R.string.ChannelRemoveUserAdmin) };
                    } else if (type == 2) {
                        items = new CharSequence[] {
                                LocaleController.getString("ChannelRemoveUser", R.string.ChannelRemoveUser) };
                    }
                    builder.setItems(items, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (i == 0) {
                                if (type == 0) {
                                    participants.remove(finalParticipant);
                                    listViewAdapter.notifyDataSetChanged();
                                    TLRPC.TL_channels_kickFromChannel req = new TLRPC.TL_channels_kickFromChannel();
                                    req.kicked = false;
                                    req.user_id = MessagesController.getInputUser(finalParticipant.user_id);
                                    req.channel = MessagesController.getInputChannel(chatId);
                                    ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                                        @Override
                                        public void run(TLObject response, TLRPC.TL_error error) {
                                            if (response != null) {
                                                final TLRPC.Updates updates = (TLRPC.Updates) response;
                                                MessagesController.getInstance().processUpdates(updates, false);
                                                if (!updates.chats.isEmpty()) {
                                                    AndroidUtilities.runOnUIThread(new Runnable() {
                                                        @Override
                                                        public void run() {
                                                            TLRPC.Chat chat = updates.chats.get(0);
                                                            MessagesController.getInstance()
                                                                    .loadFullChat(chat.id, 0, true);
                                                        }
                                                    }, 1000);
                                                }
                                            }
                                        }
                                    });
                                } else if (type == 1) {
                                    setUserChannelRole(
                                            MessagesController.getInstance().getUser(finalParticipant.user_id),
                                            new TLRPC.TL_channelRoleEmpty());
                                } else if (type == 2) {
                                    MessagesController.getInstance().deleteUserFromChat(chatId,
                                            MessagesController.getInstance().getUser(finalParticipant.user_id),
                                            null);
                                }
                            }
                        }
                    });
                    showDialog(builder.create());
                    return true;
                } else {
                    return false;
                }
            }
        });
    }

    if (loadingUsers) {
        emptyView.showProgress();
    } else {
        emptyView.showTextView();
    }
    return fragmentView;
}

From source file:com.redwoodsystems.android.apps.LightingListFragment.java

private void setupScenesList() {
    Log.d(TAG, "setupScenesList called");
    ListView listView = (ListView) getActivity().findViewById(android.R.id.list);
    TextView dummy = new TextView(getActivity());
    ImageView dummy2 = new ImageView(getActivity());
    listView.addFooterView(dummy, null, true);
    listView.setFooterDividersEnabled(true);
    listView.addHeaderView(dummy2, null, true);
    listView.setHeaderDividersEnabled(true);
    int[] colors = { 0, 0xFFF47836, 0 }; // Pantone172 for the example
    listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
    listView.setDividerHeight(1);

    //TODO: set Empty Text inside View
    //setEmptyText("No Scenes found");

    mSceneAdapter = new SceneAdapter(getActivity(), R.layout.scene_item_layout, R.id.sceneText);

    setListAdapter(mSceneAdapter);//from   ww  w . ja va 2  s .c om

    Uri dummyUri = null;
    Bundle params = new Bundle();
    Bundle args = new Bundle();
    args.putParcelable(ARGS_URI, dummyUri);
    args.putParcelable(ARGS_PARAMS, params);

    // Initialize the Loader.
    Log.d(TAG, "calling initLoader..");
    getActivity().getSupportLoaderManager().initLoader(LOADER_SCENES, null, this);

}

From source file:com.app4am.app4am.MainTopicListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (savedInstanceState != null) {
        mPosition = savedInstanceState.getInt(SwipeRefreshFragmentInterface.FRAGMENT_POSITION);
    }/*from   w ww. j av  a  2 s. c o m*/

    // Change the colors displayed by the SwipeRefreshLayout by providing it with 4
    // color resource ids
    setColorSchemeResources(R.color.color_scheme_1_1, R.color.color_scheme_1_2, R.color.color_scheme_1_3,
            R.color.color_scheme_1_4);
    // Set list view background color.
    view.setBackgroundResource(R.color.color_common_list_background);

    // Attach topic banner. The banner is dynamically loaded from the server.
    // TODO: Real image source url.
    ListView listView = getListView();
    listView.addHeaderView(mHeaderView);

    ImageView imageViewTopicBanner = (ImageView) mHeaderView.findViewById(R.id.iv_topic_banner);
    int cornerRadiusInPx = getResources()
            .getDimensionPixelSize(R.dimen.topic_list_item_background_corner_radius);
    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .displayer(new RoundedBitmapDisplayer(cornerRadiusInPx)) //rounded corner bitmap
            .cacheInMemory(true).build();

    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.displayImage("assets://todo_topic_banner_1.png", imageViewTopicBanner, options);

    // List item divider and background color
    listView.setDivider(getResources().getDrawable(R.drawable.common_list_divider));
    listView.setDividerHeight((int) getResources().getDimension(R.dimen.common_list_divider_height));
    listView.setBackgroundResource(R.color.color_common_list_background);
    listView.setCacheColorHint(0);

    // List selector
    listView.setSelector(R.drawable.list_view_selector);
    listView.setDrawSelectorOnTop(true);

    // Event handler
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO: Open topic information page (B01).
            Log.d(LOG_TAG, "on click");
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // Open topic introduction page (B02).
            onOpenTopicIntroduction();
            return true;
        }
    });

    /**
     * Create an ArrayAdapter to contain the data for the ListView. Each item in the ListView
     * uses the system-defined simple_list_item_1 layout that contains one TextView.
     */
    ListAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.topic_list_item, R.id.textView,
            Cheeses.randomList(LIST_ITEM_COUNT));

    // Set the adapter between the ListView and its backing data.
    setListAdapter(adapter);

    // BEGIN_INCLUDE (setup_refreshlistener)
    /**
     * Implement {@link android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener}. When users do the "swipe to
     * refresh" gesture, SwipeRefreshLayout invokes
     * {@link android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener#onRefresh onRefresh()}. In
     * {@link android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener#onRefresh onRefresh()}, call a method that
     * refreshes the content. Call the same method in response to the Refresh action from the
     * action bar.
     */
    setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.i(LOG_TAG, "onRefresh called from SwipeRefreshLayout");

            initiateRefresh();
        }
    });
    // END_INCLUDE (setup_refreshlistener)

}

From source file:org.michaelbel.bottomsheet.BottomSheet.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (backgroundColor == 0) {
        backgroundColor = darkTheme ? 0xFF424242 : 0xFFFFFFFF;
    }/*from www.  jav a 2  s . c o m*/

    if (titleTextColor == 0) {
        titleTextColor = darkTheme ? 0xB3FFFFFF : 0x8A000000;
    }

    if (itemTextColor == 0) {
        itemTextColor = darkTheme ? 0xFFFFFFFF : 0xDE000000;
    }

    if (iconColor == 0) {
        iconColor = darkTheme ? 0xFFFFFFFF : 0x8A000000;
    }

    if (itemSelector == 0) {
        itemSelector = darkTheme ? R.drawable.selectable_dark : R.drawable.selectable_light;
    }

    Window window = getWindow();
    window.setWindowAnimations(R.style.DialogNoAnimation);
    setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (containerView == null) {
        containerView = new FrameLayout(getContext()) {
            @Override
            public boolean hasOverlappingRendering() {
                return false;
            }
        };
        if (Build.VERSION.SDK_INT >= 16) {
            containerView.setBackground(shadowDrawable);
        } else {
            containerView.setBackgroundDrawable(shadowDrawable);
        }
        containerView.setPadding(0, backgroundPaddingTop, 0, Utils.dp(getContext(), 8));
    }

    if (Build.VERSION.SDK_INT >= 21) {
        containerView.setFitsSystemWindows(true);
    }

    containerView.setVisibility(View.INVISIBLE);
    containerView.setBackgroundColor(backgroundColor);

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;

    containerView.setLayoutParams(params);
    container.addView(containerView, 0);

    if (customView != null) {
        if (customView.getParent() != null) {
            ViewGroup viewGroup = (ViewGroup) customView.getParent();
            viewGroup.removeView(customView);
        }

        FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) containerView.getLayoutParams();
        params1.width = ViewGroup.LayoutParams.MATCH_PARENT;
        params1.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        params1.gravity = Gravity.START | Gravity.TOP;

        containerView.addView(customView, params1);
    } else {
        int topOffset = 0;

        if (titleText != null) {
            TextView titleTextView = new TextView(getContext());
            titleTextView.setLines(1);
            titleTextView.setMaxLines(1);
            titleTextView.setSingleLine(true);
            titleTextView.setText(titleText);
            titleTextView.setTextColor(titleTextColor);
            titleTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
            titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
            titleTextView.setGravity(Gravity.CENTER_VERTICAL);

            FrameLayout.LayoutParams params0 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    Utils.dp(getContext(), 56));
            params0.gravity = Gravity.START | Gravity.TOP;
            params0.leftMargin = Utils.dp(getContext(), 16);
            params0.rightMargin = Utils.dp(getContext(), 16);

            titleTextView.setLayoutParams(params0);
            containerView.addView(titleTextView);
            titleTextView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });
            topOffset += 56;
        }

        BottomSheetAdapter adapter = new BottomSheetAdapter();

        if (mItems != null || mItemsRes != null) {
            if (contentType == LIST) {
                FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                params2.topMargin = Utils.dp(getContext(), topOffset);

                ListView listView = new ListView(getContext());
                listView.setSelector(itemSelector);
                listView.setDividerHeight(0);
                listView.setAdapter(adapter);
                listView.setDrawSelectorOnTop(true);
                listView.setVerticalScrollBarEnabled(false);
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                        dismissWithButtonClick(i);
                    }
                });
                listView.setLayoutParams(params2);
                containerView.addView(listView);
            } else if (contentType == GRID) {
                FrameLayout.LayoutParams params3 = new FrameLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

                GridView gridView = new GridView(getContext());
                gridView.setSelector(itemSelector);
                gridView.setAdapter(adapter);
                gridView.setNumColumns(3);
                gridView.setVerticalScrollBarEnabled(false);
                gridView.setVerticalSpacing(Utils.dp(getContext(), 16));
                gridView.setPadding(Utils.dp(getContext(), 0), Utils.dp(getContext(), topOffset + 8),
                        Utils.dp(getContext(), 0), Utils.dp(getContext(), 16));
                gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                        dismissWithButtonClick(i);
                    }
                });
                gridView.setLayoutParams(params3);
                containerView.addView(gridView);
            }

            if (mItems != null) {
                for (int a = 0; a < mItems.length; a++) {
                    items.add(new Item(mItems[a], mIcons != null ? mIcons[a] : 0));
                }
            } else {
                for (int a = 0; a < mItemsRes.length; a++) {
                    items.add(new Item(getContext().getText(mItemsRes[a]), mIcons != null ? mIcons[a] : 0));
                }
            }

            adapter.notifyDataSetChanged();
        }
    }

    WindowManager.LayoutParams params4 = window.getAttributes();
    params4.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params4.gravity = Gravity.TOP | Gravity.START;
    params4.dimAmount = 0;
    params4.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    if (!focusable) {
        params4.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    }
    params4.height = ViewGroup.LayoutParams.MATCH_PARENT;
    window.setAttributes(params4);
}

From source file:com.conferenceengineer.android.iosched.ui.SocialStreamFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView lv = getListView();
    /*if (!UIUtils.isTablet(getActivity())) {
    view.setBackgroundColor(getResources().getColor(R.color.stream_spacer_color));
    }*///from w  ww .jav a2s .co  m

    // Add some padding if the parent layout is too wide to avoid stretching the items too much
    // emulating the activity_letterboxed_when_large layout behaviour
    if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {

        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.social_stream_padding_vertical);
        if (verticalMargin > 0) {
            lv.setClipToPadding(false);
            lv.setPadding(0, verticalMargin, 0, verticalMargin);
        }
    }

    lv.setOnScrollListener(this);
    lv.setDrawSelectorOnTop(true);
    lv.setDivider(getResources().getDrawable(R.drawable.stream_list_divider));
    lv.setDividerHeight(getResources().getDimensionPixelSize(R.dimen.stream_divider_height));
    //view.setBackgroundColor(getResources().getColor(R.color.stream_list_bg_color));

    setListAdapter(mStreamAdapter);
}

From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java

/**
 * Screen to select the answer types that will be present in the test
 *//*from  w w  w. java 2 s . co m*/
private void selectAnswerTypes() {
    ListView checkBoxesList;
    AnswerTypesArrayAdapter answerTypesAdapter;

    screenStep = ScreenStep.ANSWER_TYPES;

    setLayout(R.layout.tests_answer_types);

    checkBoxesList = (ListView) findViewById(R.id.testAnswerTypesList);
    answerTypesAdapter = new AnswerTypesArrayAdapter(this, R.array.testAnswerTypes,
            R.array.testAnswerTypesNames, R.layout.list_item_multiple_choice);
    checkBoxesList.setAdapter(answerTypesAdapter);
    checkBoxesList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    checkBoxesList.setOnItemClickListener(tagsAnswersTypeItemClickListener);
    checkBoxesList.setDividerHeight(0);
}

From source file:com.sentaroh.android.Utilities.ContextMenu.CustomContextMenuFragment.java

private void initViewWidget() {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "initViewWidget");

    //      CommonDialog.setDlgBoxSizeCompact(mDialog);

    LinearLayout dlg_ll = new LinearLayout(getActivity());
    dlg_ll.setOrientation(LinearLayout.VERTICAL);
    TextView dlg_tv = new TextView(getActivity());
    dlg_tv.setBackgroundColor(Color.WHITE);
    dlg_tv.setTextColor(Color.BLACK);
    //        dlg_tv.setTextSize(32);
    dlg_tv.setGravity(android.view.Gravity.CENTER_VERTICAL | android.view.Gravity.CENTER_HORIZONTAL);

    ListView dlg_lv = new ListView(getActivity());
    dlg_lv.setBackgroundColor(Color.WHITE);

    dlg_ll.addView(dlg_tv);/*from ww  w. j a  v a 2 s  .c  om*/
    dlg_ll.addView(dlg_lv);

    mDialog.setContentView(dlg_ll);

    if (mDialogTitle.length() != 0) {
        dlg_tv.setText(mDialogTitle);
        dlg_tv.setVisibility(TextView.VISIBLE);
    } else
        dlg_tv.setVisibility(TextView.GONE);

    dlg_lv.setAdapter(mMenuAdapter);
    dlg_lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
            CustomContextMenuItem item = (CustomContextMenuItem) mMenuAdapter.getItem(idx);
            if (item.menu_enabled) {
                if (idx < mClickHandler.size()) {
                    mClickHandler.get(idx).onClick(item.text);
                }
                mFragment.dismiss();
            }
        }
    });
    dlg_lv.setScrollingCacheEnabled(false);
    dlg_lv.setScrollbarFadingEnabled(false);
    //      int[] colors = {0, 0xFFFF0000, 0}; // red for the example
    //      lv.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
    dlg_lv.setDividerHeight(0);

}

From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java

/**
 * Screen to select the tags that will be present in the test
 *//*from ww  w. jav  a2 s.  com*/
private void selectTags() {
    ListView checkBoxesList;
    TagsArrayAdapter tagsAdapter;
    List<TestTag> allTagsList = dbHelper.getOrderedCourseTags(Constants.getSelectedCourseCode());

    screenStep = ScreenStep.TAGS;

    //Add "All tags" item in list's top
    allTagsList.add(0, new TestTag(0, getResources().getString(R.string.allMsg), 0));

    setLayout(R.layout.tests_tags);

    checkBoxesList = (ListView) findViewById(R.id.testTagsList);
    tagsAdapter = new TagsArrayAdapter(this, R.layout.list_item_multiple_choice, allTagsList);
    checkBoxesList.setAdapter(tagsAdapter);
    checkBoxesList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    checkBoxesList.setOnItemClickListener(tagsAnswersTypeItemClickListener);
    checkBoxesList.setDividerHeight(0);
}

From source file:org.solovyev.android.messenger.BaseListFragment.java

protected void fillListView(@Nonnull ListView lv, @Nonnull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        lv.setScrollbarFadingEnabled(true);
    }/*  w  w  w . ja  v  a2 s.c  o m*/
    lv.setBackgroundDrawable(null);
    lv.setCacheColorHint(Color.TRANSPARENT);
    ListViewScroller.createAndAttach(lv, this);
    lv.setFastScrollEnabled(true);

    lv.setTextFilterEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        lv.setOverscrollFooter(null);
    }

    lv.setVerticalFadingEdgeEnabled(false);
    lv.setFocusable(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    }
    lv.setDivider(new ColorDrawable(Color.LTGRAY));
    lv.setDividerHeight(1);
}

From source file:com.plined.liftlog.WorkoutInstanceFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    if (mInflatedLayout == null) {
        mInflatedLayout = inflater.inflate(R.layout.f_workout_instance, parent, false);

        //Make our listview context menu sensitive
        ListView listView = (ListView) mInflatedLayout.findViewById(android.R.id.list);
        registerForContextMenu(listView);

        //Set our divider to be non-existent
        listView.setDividerHeight(0);

        //Crate our gui timer
        mGuiTimer = new GUITimer(mInflatedLayout.findViewById(R.id.t_timer_bar_lay_root),
                (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE), getActivity());
    } else {//ww w  .  j a v  a  2 s  .c om
        //HACK: This works... for some reason. I wish I knew why. If I did the alternative (getListView().getParent()) it was crashing.
        ((ViewGroup) mInflatedLayout.getParent()).removeAllViews();
    }

    return mInflatedLayout;
}