Java Code Examples for android.widget.listview#setDivider()

The following examples show how to use android.widget.listview#setDivider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectItemQuizView.java    From android-topeka with Apache License 2.0 6 votes vote down vote up
@Override
protected View createQuizContentView() {
    Context context = getContext();
    mListView = new ListView(context);
    mListView.setDivider(null);
    mListView.setSelector(R.drawable.selector_button);
    mListView.setAdapter(
            new OptionsQuizAdapter(getQuiz().getOptions(), R.layout.item_answer_start,
                    context, true));
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            allowAnswer();
            toggleAnswerFor(position);
        }
    });
    return mListView;
}
 
Example 2
Source File: UsbChooserPreferences.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    addPreferencesFromResource(R.xml.usb_chooser_preferences);
    ListView listView = (ListView) getView().findViewById(android.R.id.list);
    mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
    listView.setEmptyView(mEmptyView);
    listView.setDivider(null);

    String category = getArguments().getString(SingleCategoryPreferences.EXTRA_CATEGORY);
    mCategory = SiteSettingsCategory.fromString(category);
    String title = getArguments().getString(SingleCategoryPreferences.EXTRA_TITLE);
    getActivity().setTitle(title);

    setHasOptionsMenu(true);

    super.onActivityCreated(savedInstanceState);
}
 
Example 3
Source File: SingleCategoryPreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    addPreferencesFromResource(R.xml.website_preferences);
    ListView listView = (ListView) getView().findViewById(android.R.id.list);
    mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
    listView.setEmptyView(mEmptyView);
    listView.setDivider(null);

    mClearButton = (Button) getView().findViewById(R.id.clear_button);
    if (mClearButton != null) {
        mClearButton.setOnClickListener(this);
    }

    String title = getArguments().getString(EXTRA_TITLE);
    if (title != null) getActivity().setTitle(title);

    configureGlobalToggles();

    setHasOptionsMenu(true);

    super.onActivityCreated(savedInstanceState);
}
 
Example 4
Source File: RollbackActivity.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
@Override
    public void onCreate(Bundle savedInstanceState) {
//        Aptoide.getThemePicker().setAptoideTheme(this);
        super.onCreate(savedInstanceState);
        setContentView(getContentView());
        bindViews();

        rollBackAdapter = new RollBackAdapter(this);

        ListView lView = (ListView) findViewById(R.id.rollback_list);
        lView.setDivider(null);

        RollbackSectionListAdapter adapter = new RollbackSectionListAdapter(getLayoutInflater(), rollBackAdapter);

        lView.setAdapter(adapter);

        mToolbar.setCollapsible(false);

        setSupportActionBar(mToolbar);

        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(true);
        getSupportActionBar().setTitle(getString(R.string.rollback));
    }
 
Example 5
Source File: DividerProcessor.java    From injor with Apache License 2.0 6 votes vote down vote up
@Override
public void process(View view, String resName, ResourceManager resourceManager, boolean isInUiThread) {
	if (view instanceof ListView) {
		final Drawable divider = resourceManager.getDrawable(resName);
		if (divider != null) {
			final ListView listView = (ListView) view;
			if (isInUiThread) {
				listView.setDivider(divider);
			} else {
				UITaskManager.getInstance().post(new Runnable() {
					@Override
					public void run() {
						listView.setDivider(divider);
					}
				});
			}
		}
	}
}
 
Example 6
Source File: ListViewFragment.java    From spruce-android with MIT License 6 votes vote down vote up
@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 7
Source File: EntitySelectViewSetup.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
public static void setupDivider(Context context, ListView view, boolean useNewDivider) {
    if (useNewDivider) {
        int viewWidth = view.getWidth();
        // sometimes viewWidth is 0, and in this case we default to a reasonable value taken from dimens.xml
        int dividerWidth;
        if (viewWidth == 0) {
            dividerWidth = (int)context.getResources().getDimension(R.dimen.entity_select_divider_left_inset);
        } else {
            dividerWidth = (int)(viewWidth / 6.0);
        }
        dividerWidth += (int)context.getResources().getDimension(R.dimen.row_padding_horizontal);

        LayerDrawable dividerDrawable = (LayerDrawable)context.getResources().getDrawable(R.drawable.divider_case_list_modern);
        dividerDrawable.setLayerInset(0, dividerWidth, 0, 0, 0);

        view.setDivider(dividerDrawable);
        view.setDividerHeight((int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1,
                context.getResources().getDisplayMetrics()));
    } else {
        view.setDivider(null);
    }
}
 
Example 8
Source File: AbsListContentWindow.java    From NetCloud_android with GNU General Public License v2.0 5 votes vote down vote up
private void initView(Context context){

        mContentView = new FrameLayout(context);

        mListView = new ListView(context);
        mListView.setDividerHeight(ScreenUtils.dp2px(1.5f));
        mListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
        mListView.setSelector(R.drawable.list_item_bg);
        mListView.setBackgroundColor(Color.TRANSPARENT);
        mAdapter = new MyAdapter();

        mContentView.addView(mListView);

        mEmptyView = new TextView(context);
        mEmptyView.setTextSize(TypedValue.COMPLEX_UNIT_PX, ResTools.getDimen(R.dimen.textsize2));
        mEmptyView.setTextColor(ResTools.getColor(R.color.text));
        mEmptyView.setGravity(Gravity.CENTER);
        mEmptyView.setText("empty");
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.CENTER_HORIZONTAL;
        lp.topMargin = (int)(ScreenUtils.getScreenSize().y*0.38f);
        mContentView.addView(mEmptyView, lp);

        mLoading = new TextView(context);
        mLoading.setTextSize(TypedValue.COMPLEX_UNIT_PX, ResTools.getDimen(R.dimen.textsize2));
        mLoading.setTextColor(ResTools.getColor(R.color.text));
        mLoading.setText("loading...");
        lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.CENTER_HORIZONTAL;
        lp.topMargin = ScreenUtils.getScreenSize().y/3;
        mContentView.addView(mLoading, lp);
    }
 
Example 9
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
Example 10
Source File: ListViewDividerPaint.java    From NightOwl with Apache License 2.0 5 votes vote down vote up
@Override
public void draw(View view, Object value) {
    ListView listView = (ListView) view;
    int listHeight = listView.getDividerHeight();
    listView.setDivider((Drawable) value);
    listView.setDividerHeight(listHeight);
}
 
Example 11
Source File: MyListActivity.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_mylist);
	mListView = (ListView) findViewById(R.id.activity_mylist_listview);
	mListView.setDivider(null);
}
 
Example 12
Source File: FilePicker.java    From AndroidPicker with MIT License 5 votes vote down vote up
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    rootLayout.setBackgroundColor(Color.WHITE);

    ListView listView = new ListView(activity);
    listView.setBackgroundColor(Color.WHITE);
    listView.setDivider(new ColorDrawable(0xFFDDDDDD));
    listView.setDividerHeight(1);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);
    rootLayout.addView(listView);

    emptyView = new TextView(activity);
    LinearLayout.LayoutParams txtParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    txtParams.gravity = Gravity.CENTER;
    emptyView.setLayoutParams(txtParams);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setTextColor(Color.BLACK);
    rootLayout.addView(emptyView);

    return rootLayout;
}
 
Example 13
Source File: SettingsFragment.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle bundle) {
	super.onActivityCreated(bundle);

	final ListView listView = getActivity().findViewById(android.R.id.list);
	if (listView != null) {
		listView.setDivider(null);
	}
}
 
Example 14
Source File: SettingFragment.java    From MemoryCleaner with Apache License 2.0 5 votes vote down vote up
@Override public void initPreferenceListView(View view) {
    ListView listView = (ListView) view.findViewById(android.R.id.list);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDivider(
            new ColorDrawable(getResources().getColor(R.color.grey)));
    listView.setDividerHeight((int) getResources().getDimension(
            R.dimen.preference_divider_height));
    listView.setFooterDividersEnabled(false);
    listView.setHeaderDividersEnabled(false);
}
 
Example 15
Source File: PXDividerStyler.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
@Override
public void applyStylesWithContext(PXStylerContext stylerContext) {
    ListView listView = (ListView) stylerContext.getStyleable();
    // create the divider drawable and set it to the list
    int width = listView.getWidth();
    if (width <= 0) {
        View parent = (View) PXStyleAdapter.getStyleAdapter(listView).getParent(listView);
        if (parent != null) {
            width = parent.getWidth();
        }
    }
    listView.setDivider(PXDrawableUtil.createDrawable(width, listView.getDividerHeight(),
            stylerContext.getDividerFill()));
}
 
Example 16
Source File: SearchEnginePreference.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListView = (ListView) getView().findViewById(android.R.id.list);
    int marginTop = getActivity().getResources().getDimensionPixelSize(
            R.dimen.search_engine_list_margin_top);
    MarginLayoutParams layoutParams = (MarginLayoutParams) mListView.getLayoutParams();
    layoutParams.setMargins(0, marginTop, 0, 0);
    mListView.setLayoutParams(layoutParams);
    mListView.setAdapter(mSearchEngineAdapter);
    mListView.setDivider(null);
}
 
Example 17
Source File: UpApiListActivity.java    From UPPlatform_Android_SDK with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    getWindow().setBackgroundDrawableResource(R.color.white);

    Intent intent = getIntent();
    if (intent != null) {
        mClientSecret = intent.getStringExtra(UpPlatformSdkConstants.CLIENT_SECRET);
    }

    ListView listView = getListView();
    LayoutInflater inflater = LayoutInflater.from(this);
    TextView header = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, listView, false);
    header.setText("List of UP Platform API Calls");
    header.setTextColor(Color.WHITE);
    header.setBackgroundColor(Color.DKGRAY);
    header.setGravity(Gravity.CENTER);
    listView.addHeaderView(header);

    String[] displayStrings = new String[UpPlatformSdkConstants.RestApiRequestType.size];
    int index = 0;
    for (UpPlatformSdkConstants.RestApiRequestType r: UpPlatformSdkConstants.RestApiRequestType.values()) {
        displayStrings[index] = r.toString();
        index++;
    }

    setListAdapter(new ArrayAdapter<String>(this, R.layout.up_api_list, displayStrings));

    ColorDrawable sage = new ColorDrawable(this.getResources().getColor(R.color.black_overlay));
    listView.setDivider(sage);
    listView.setDividerHeight(1);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    mAccessToken = preferences.getString(UpPlatformSdkConstants.UP_PLATFORM_ACCESS_TOKEN, null);

    if (mAccessToken != null) {
        ApiManager.getRequestInterceptor().setAccessToken(mAccessToken);
        listView.setOnItemClickListener(restApiListener());
    }
}
 
Example 18
Source File: PhotoAlbumPickerActivity.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public View createView(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.setBackText(context.getString(R.string.Cancel));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == item_photos) {
                refreshShowPic();//刷新照片目录
            } else if (id == item_video) {
                refreshShowVedio();//刷新录像目录
            }
        }
    });


    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
    //==============videos pick====================
    int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
    actionBar.setTitle(context.getString(res));
    selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
            AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
            .getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    // layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(R.string.NoPhotos);
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);


    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}
 
Example 19
Source File: PopupWindowList.java    From WechatPopupWindow with Apache License 2.0 4 votes vote down vote up
public void show() {
    if (mAnchorView == null) {
        throw new IllegalArgumentException("PopupWindow show location view can  not be null");
    }
    if (mItemData == null) {
        throw new IllegalArgumentException("please fill ListView Data");
    }
    mPopView = new ListView(mContext);
    mPopView.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.white));
    mPopView.setVerticalScrollBarEnabled(false);
    mPopView.setDivider(null);
    mPopView.setAdapter(new ArrayAdapter<>(mContext,
            android.R.layout.simple_list_item_1, mItemData));
    if (mItemClickListener != null) {
        mPopView.setOnItemClickListener(mItemClickListener);
    }
    mPopView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    if (mPopupWindowWidth == 0) {
        mPopupWindowWidth = mDeviceWidth / 3;
    }
    if (mPopupWindowHeight == 0) {
        mPopupWindowHeight = mItemData.size() * mPopView.getMeasuredHeight();
        if (mPopupWindowHeight > mDeviceHeight / 2) {
            mPopupWindowHeight = mDeviceHeight / 2;
        }
    }
    mPopupWindow = new PopupWindow(mPopView, mPopupWindowWidth, mPopupWindowHeight);
    if (mPopAnimStyle != 0) {
        mPopupWindow.setAnimationStyle(mPopAnimStyle);
    }
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setFocusable(mModal);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable(mContext.getResources(), (Bitmap) null));


    Rect location = locateView(mAnchorView);
    if (location != null) {
        int x;
        //view中心点X坐标
        int xMiddle = location.left + mAnchorView.getWidth() / 2;
        if (xMiddle > mDeviceWidth / 2) {
            //在右边
            x = xMiddle - mPopupWindowWidth;
        } else {
            x = xMiddle;
        }
        int y;
        //view中心点Y坐标
        int yMiddle = location.top + mAnchorView.getHeight() / 2;
        if (yMiddle > mDeviceHeight / 2) {
            //在下方
            y = yMiddle - mPopupWindowHeight;
        } else {
            //在上方
            y = yMiddle;
        }
        mPopupWindow.showAtLocation(mAnchorView, Gravity.NO_GRAVITY, x, y);
    }
}
 
Example 20
Source File: ContributorsFragment.java    From GithubContributorsLib with Apache License 2.0 4 votes vote down vote up
protected void setupListView(ListView listView) {
    if (listView != null) {
        listView.setDivider(null);
        listView.setOnScrollListener(this);
    }
}