Java Code Examples for android.widget.ListView.setDividerHeight()

The following are Jave code examples for showing how to use setDividerHeight() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: searchablespinner   File: SearchableSpinner.java   View Source Code Vote up 7 votes
public SearchableSpinner(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mContext = context;
    getAttributeSet(attrs, defStyleAttr, defStyleRes);

    final LayoutInflater factory = LayoutInflater.from(context);
    factory.inflate(R.layout.view_searchable_spinner, this, true);

    mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list, this, false);
    mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
    if (mListItemDivider != null) {
        mSpinnerListView.setDivider(mListItemDivider);
        mSpinnerListView.setDividerHeight(mListDividerSize);
    }
    mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
    mSpinnerListView.setEmptyView(mEmptyTextView);
}
 
Example 2
Project: android-example   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    AdapterAndroidVersion adapterAndroidVersion = new AdapterAndroidVersion(this, 0, getAndroidVer());

    ListView listView = findViewById(R.id.mainList);
    listView.setDividerHeight(0);
    listView.setAdapter(adapterAndroidVersion);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            ModelAndroidVersion androidVersion = getAndroidVer().get(i);
            Snackbar.make(findViewById(R.id.rootView), androidVersion.codeName, Snackbar.LENGTH_SHORT).show();

        }
    });
}
 
Example 3
Project: MainCalendar   File: FilePicker.java   View Source Code Vote up 6 votes
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setBackgroundColor(Color.WHITE);
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    ListView listView = new ListView(activity);
    listView.setBackgroundColor(Color.WHITE);
    listView.setDivider(new ColorDrawable(0xFFDDDDDD));
    listView.setDividerHeight(1);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setSelector(R.color.itemSelected);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);
    rootLayout.addView(listView);
    return rootLayout;
}
 
Example 4
Project: spruce-android   File: ListViewFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) {
    listView = (ListView) container.findViewById(R.id.list_view);

    // Create the animator after the list view has finished laying out
    listView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            initSpruce();
        }
    });

    // Mock data objects
    List<ExampleData> placeHolderList = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        placeHolderList.add(new ExampleData());
    }

    // Remove default dividers and set adapter
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setAdapter(new ListViewAdapter(placeHolderList));

    return inflater.inflate(R.layout.list_view_fragment, container, false);
}
 
Example 5
Project: GitHub   File: IosCenterItemHolder.java   View Source Code Vote up 5 votes
@Override
protected void findViews() {
    lv = (ListView) rootView.findViewById(R.id.lv);

    lv.setDivider(new ColorDrawable(lv.getResources().getColor(R.color.line_dd)));
    lv.setDividerHeight(1);
}
 
Example 6
Project: GitHub   File: IosActionSheetHolder.java   View Source Code Vote up 5 votes
@Override
protected void findViews() {
    lv = (ListView) rootView.findViewById(R.id.lv);

    lv.setDivider(new ColorDrawable(lv.getResources().getColor(R.color.line_dd)));
    lv.setDividerHeight(1);
    btnBottom = (Button) rootView.findViewById(R.id.btn_bottom);
}
 
Example 7
Project: CCDownload   File: PlayFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	context = getActivity().getApplicationContext();
	RelativeLayout playLayout = new RelativeLayout(context);
	playLayout.setBackgroundColor(Color.WHITE);
	LayoutParams playLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	playLayout.setLayoutParams(playLayoutParams);
	
	playListView = new ListView(context);
	playListView.setDivider(getResources().getDrawable(R.drawable.line));
	playListView.setDividerHeight(2);
	playListView.setPadding(10, 10, 10, 10);
	LayoutParams playListLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	playLayout.addView(playListView, playListLayoutParams);

	// 生成动态数组,加入数据
	pairs = new ArrayList<Pair<String,Integer>>();
	for (int i = 0; i < playVideoIds.length; i++) {
		Pair<String, Integer> pair = new Pair<String, Integer>(playVideoIds[i], R.drawable.play);
		pairs.add(pair);
	}

	videoListViewAdapter = new VideoListViewAdapter(context, pairs);
	playListView.setAdapter(videoListViewAdapter);
	playListView.setOnItemClickListener(onItemClickListener);

	return playLayout;
}
 
Example 8
Project: LuaViewPlayground   File: UDBaseListView.java   View Source Code Vote up 5 votes
/**
 * 设置分隔条高度
 *
 * @param height
 * @return
 */
@Override
public UDBaseListOrRecyclerView setMiniSpacing(int height) {
    final ListView lv = getListView();
    if (lv != null && height >= 0) {
        lv.setDividerHeight(height);
    }
    return this;
}
 
Example 9
Project: qmui   File: QDQQFaceBasePagerView.java   View Source Code Vote up 5 votes
public QDQQFaceBasePagerView(Context context) {
    super(context);

    mTestData = new QDQQFaceTestData();

    setOrientation(VERTICAL);
    mListView = new ListView(context);
    LinearLayout.LayoutParams listLp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
    listLp.weight = 1;
    mListView.setLayoutParams(listLp);
    mListView.setDivider(null);
    mListView.setDividerHeight(0);
    mListView.setAdapter(new MyAdapter());
    addView(mListView);

    mLogTv = new TextView(context);
    LinearLayout.LayoutParams logLp = new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dp2px(context, 60));
    mLogTv.setLayoutParams(logLp);
    mLogTv.setTextSize(12);
    mLogTv.setBackgroundResource(R.drawable.qmui_divider_top_bitmap);
    int paddingHor = QMUIDisplayHelper.dp2px(context, 16);
    mLogTv.setPadding(paddingHor, 0, paddingHor, 0);
    mLogTv.setTextColor(ContextCompat.getColor(context, R.color.qmui_config_color_black));
    mLogTv.setMovementMethod(QMUIScrollingMovementMethod.getInstance());
    addView(mLogTv);
}
 
Example 10
Project: MainCalendar   File: WeekPicker.java   View Source Code Vote up 5 votes
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setOrientation(LinearLayout.VERTICAL);

    mListView = new ListView(activity);
    mListView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    mListView.getLayoutParams().height = screenHeightPixels/4;
    mListView.setPadding(30, 10, 30, 10);
    // 去掉分割线
    mListView.setDividerHeight(0);
    mListView.setAdapter(mWeekAdapter);
    rootLayout.addView(mListView);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                                int arg2, long arg3) {
            // 取得ViewHolder对象,这样就省去了通过层层的findViewById去实例化我们需要的cb实例的步骤
            WeekAdapter.ViewHolder holder = (WeekAdapter.ViewHolder) arg1.getTag();
            // 改变CheckBox的状态
            holder.cb.toggle();
            // 将CheckBox的选中状况记录下来
            mWeekAdapter.setIsSelected(arg2, holder.cb.isChecked());
        }
    });
    setTitleText(mTitle);
    return rootLayout;
}
 
Example 11
Project: chromium-for-android-56-debug-video   File: PassphraseTypeDialogFragment.java   View Source Code Vote up 5 votes
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.sync_passphrase_types, null);

    // Configure the passphrase type list
    ListView list = (ListView) v.findViewById(R.id.passphrase_types);
    Adapter adapter = createAdapter(getCurrentTypeFromArguments());
    list.setAdapter(adapter);
    list.setId(R.id.passphrase_type_list);
    list.setOnItemClickListener(this);
    list.setDividerHeight(0);
    PassphraseType currentType = getCurrentTypeFromArguments();
    list.setSelection(adapter.getPositionForType(currentType));

    // Configure the hint to reset the passphrase settings
    // Only show this hint if encryption has been set to use sync passphrase
    if (currentType == PassphraseType.CUSTOM_PASSPHRASE) {
        TextView instructionsView = (TextView) v.findViewById(R.id.reset_sync_text);
        instructionsView.setVisibility(View.VISIBLE);
        instructionsView.setMovementMethod(LinkMovementMethod.getInstance());
        instructionsView.setText(getResetText());
    }

    // Create and return the dialog
    return new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setNegativeButton(R.string.cancel, this)
            .setTitle(R.string.sync_passphrase_type_title)
            .setView(v)
            .create();
}
 
Example 12
Project: oma-riista-android   File: SlideMenu.java   View Source Code Vote up 5 votes
public SlideMenuView(Context context) {
    super(context);
    
    mListView = new ListView(context);
    mListView.setCacheColorHint(0);
    mListView.setDividerHeight(0);
    mListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
    mListView.setVerticalScrollBarEnabled(false);
    mListView.setOnItemClickListener(mListItemClickListener);
    addView(mListView);
}
 
Example 13
Project: QMUI_Android   File: QDQQFaceBasePagerView.java   View Source Code Vote up 5 votes
public QDQQFaceBasePagerView(Context context) {
    super(context);

    mTestData = new QDQQFaceTestData();

    setOrientation(VERTICAL);
    ListView listView = new ListView(context);
    LinearLayout.LayoutParams listLp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
    listLp.weight = 1;
    listView.setLayoutParams(listLp);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setAdapter(new MyAdapter());
    addView(listView);

    mLogTv = new TextView(context);
    LinearLayout.LayoutParams logLp = new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dp2px(context, 60));
    mLogTv.setLayoutParams(logLp);
    mLogTv.setTextSize(12);
    mLogTv.setBackgroundResource(R.drawable.qmui_divider_top_bitmap);
    int paddingHor = QMUIDisplayHelper.dp2px(context, 16);
    mLogTv.setPadding(paddingHor, 0, paddingHor, 0);
    mLogTv.setTextColor(ContextCompat.getColor(context, R.color.qmui_config_color_black));
    mLogTv.setMovementMethod(QMUIScrollingMovementMethod.getInstance());
    addView(mLogTv);
}
 
Example 14
Project: Android-Skin-Loader   File: DividerAttr.java   View Source Code Vote up 5 votes
@Override
public void apply(View view) {
	if(view instanceof ListView){
		ListView tv = (ListView)view;
		if(RES_TYPE_NAME_COLOR.equals(attrValueTypeName)){
			int color = SkinManager.getInstance().getColor(attrValueRefId);
			ColorDrawable sage = new ColorDrawable(color);
			tv.setDivider(sage);
			tv.setDividerHeight(dividerHeight);
		}else if(RES_TYPE_NAME_DRAWABLE.equals(attrValueTypeName)){
			tv.setDivider(SkinManager.getInstance().getDrawable(attrValueRefId));
		}
	}
}
 
Example 15
Project: showroom-android   File: ExpandingCollectionActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Make activity fullscreen
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    ActionBar supportActionBar = getSupportActionBar();
    if (null != supportActionBar)
        supportActionBar.hide();

    setContentView(R.layout.ec_main_activity);

    // Create adapter for pager
    ECPagerViewAdapter adapter = new ECPagerViewAdapter(this, new ExampleDataset().getDataset()) {
        @Override
        public void instantiateCard(LayoutInflater inflaterService, ViewGroup head, ListView list, final ECCardData data) {
            final CardData cardData = (CardData) data;

            // Create adapter for list inside a card and set adapter to card content
            CommentArrayAdapter commentArrayAdapter = new CommentArrayAdapter(getApplicationContext(), cardData.getListItems());
            list.setAdapter(commentArrayAdapter);
            list.setDivider(getResources().getDrawable(R.drawable.ec_list_divider));
            list.setDividerHeight((int) pxFromDp(getApplicationContext(), 0.5f));
            list.setSelector(R.color.ec_transparent);
            list.setBackgroundColor(Color.WHITE);
            list.setCacheColorHint(Color.TRANSPARENT);

            // Add gradient to root header view
            View gradient = new View(getApplicationContext());
            gradient.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.MATCH_PARENT));
            gradient.setBackgroundDrawable(getResources().getDrawable(R.drawable.ec_card_head_gradient));
            head.addView(gradient);

            // Inflate main header layout and attach it to header root view
            inflaterService.inflate(R.layout.ec_simple_head, head);

            // Set header data from data object
            TextView title = (TextView) head.findViewById(R.id.ec_title);
            title.setText(cardData.getHeadTitle());
            ImageView avatar = (ImageView) head.findViewById(R.id.ec_avatar);
            avatar.setImageResource(cardData.getPersonPictureResource());
            TextView name = (TextView) head.findViewById(R.id.ec_name);
            name.setText(cardData.getPersonName() + ":");
            TextView message = (TextView) head.findViewById(R.id.ec_message);
            message.setText(cardData.getPersonMessage());
            TextView viewsCount = (TextView) head.findViewById(R.id.ec_social_views_count);
            viewsCount.setText(" " + cardData.getPersonViewsCount());
            TextView likesCount = (TextView) head.findViewById(R.id.ec_social_likes_count);
            likesCount.setText(" " + cardData.getPersonLikesCount());
            TextView commentsCount = (TextView) head.findViewById(R.id.ec_social_comments_count);
            commentsCount.setText(" " + cardData.getPersonCommentsCount());

            // Add onclick listener to card header for toggle card state
            head.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View v) {
                    ecPagerView.toggle();
                }
            });
        }
    };

    ecPagerView = (ECPagerView) findViewById(R.id.ec_pager_element);

    ecPagerView.setPagerViewAdapter(adapter);
    ecPagerView.setBackgroundSwitcherView((ECBackgroundSwitcherView) findViewById(R.id.ec_bg_switcher_element));

    final ItemsCountView itemsCountView = (ItemsCountView) findViewById(R.id.ec_items_count_view);
    ecPagerView.setOnCardSelectedListener(new ECPagerView.OnCardSelectedListener() {
        @Override
        public void cardSelected(int newPosition, int oldPosition, int totalElements) {
            itemsCountView.update(newPosition, oldPosition, totalElements);
        }
    });
}
 
Example 16
Project: SuperSelector   File: Util.java   View Source Code Vote up 4 votes
public static void initListViewStyle(ListView listView) {
	listView.setDividerHeight(0);
	listView.setFadingEdgeLength(0);
}
 
Example 17
Project: PlusGram   File: FontsSelect.java   View Source Code Vote up 4 votes
@Override
public View createView(final Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("FontChange", R.string.FontChange));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });


    fragmentView = new FrameLayout(context);
    fragmentView.setLayoutParams(new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));


    FrameLayout frameLayout = (FrameLayout) fragmentView;


    listView = new ListView(context);

    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    listView.setBackgroundColor(preferences.getInt("prefBGColor", 0xffffffff));
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    int def = preferences.getInt("themeColor", AndroidUtilities.defColor);
    int hColor = preferences.getInt("prefHeaderColor", def);
    AndroidUtilities.setListViewEdgeEffectColor(listView, /*AvatarDrawable.getProfileBackColorForId(5)*/ hColor);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
    layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP;
    listView.setLayoutParams(layoutParams);

    initFonts(context);



    return fragmentView;
}
 
Example 18
Project: PlusGram   File: ThemStore.java   View Source Code Vote up 4 votes
@Override
public View createView(final Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("ThemeStore", R.string.ThemeStore));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });


    fragmentView = new FrameLayout(context);
    fragmentView.setLayoutParams(new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));


    FrameLayout frameLayout = (FrameLayout) fragmentView;


    listView = new ListView(context);

    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    listView.setBackgroundColor(preferences.getInt("prefBGColor", 0xffffffff));
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    int def = preferences.getInt("themeColor", AndroidUtilities.defColor);
    int hColor = preferences.getInt("prefHeaderColor", def);
    AndroidUtilities.setListViewEdgeEffectColor(listView, /*AvatarDrawable.getProfileBackColorForId(5)*/ hColor);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
    layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP;
    listView.setLayoutParams(layoutParams);

    progressDialog = new ProgressDialog(context);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setMessage(context.getString(R.string.Loading));

    if (Cashing.themes.size() < 1) {
        progressDialog.show();
        new getThemes(context, constant.GET_THEMES).execute();
    } else {
        themes = Cashing.themes;
        refreshDisplay(context);
    }

    return fragmentView;
}