android-checkbox

listview checkbox trouble in android

℡╲_俬逩灬. 提交于 2019-12-01 23:37:15
i have a trouble with listview. i added a checkbox into listview to choose items. my data is coming from sqlite so i use simple cursor adapter. length of my list is aproximatley 250 lines. i am clicking a check box.when i scroll down page (list), checkbox is clicked in every 10 lines.(for example in my screen show 10 lines data when i scroll 11th lines, this row's checkbox had clicked. how can i solve this problem. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match

How to disable checkbox when a limit is reached in android?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 21:37:27
I have 15 CheckBox and I must to stuck user when he checks more than 5. I use the method OnCheckedChangeListener to know if an item is checked, but I don't know how to limit after 5 items selected . See my code below: int lengthBox = 15; int lenghtCount = 0; // inside onCreate method final CheckBox[] checkbox = new CheckBox[lengthBox]; OnCheckedChangeListener checker = new OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton cb, boolean b) { // How can I improve this condition? if(checkbox[0].isChecked() || checkbox[1].isChecked() || checkbox[2].isChecked() ||

how can we reduce the size of checkbox please give me an idea

荒凉一梦 提交于 2019-12-01 12:21:25
How can we reduce the size of checkbox? Please give me an idea. You can define your owm state list drawable, to define different images for different states, as below: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!--When checkbox is checked--> <item android:state_checked="true" android:drawable="@drawable/img_checkbox_on" /> <!--When checkbox is not checked--> <item android:state_checked="false" android:drawable="@drawable/img_checkbox_off" /> </selector> and apply this selector to check box in xml by: <CheckBox android:layout

how can we reduce the size of checkbox please give me an idea

女生的网名这么多〃 提交于 2019-12-01 10:15:48
问题 How can we reduce the size of checkbox? Please give me an idea. 回答1: You can define your owm state list drawable, to define different images for different states, as below: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!--When checkbox is checked--> <item android:state_checked="true" android:drawable="@drawable/img_checkbox_on" /> <!--When checkbox is not checked--> <item android:state_checked="false" android:drawable="@drawable

Change default design theme to customized color

左心房为你撑大大i 提交于 2019-12-01 08:17:18
I am very new to Android Studio. As a beginner I have created a simple app just for testing purpose and to view the appearance of Android studio material theme. I am currently working with latest version ie. L preview - Studio 0.8.2 version. Here, I have just created textview, edittext, radio buttons and checkboxes. When I select male or female, it appears sky blue color. Could I be able to change sky blue color as a green or yellow color? I do not know what is the name for that. From the picture can able to see edittext, radio buttons and checkboxes selected state as a sky blue color. When I

Select all checkboxes in RecyclerView

跟風遠走 提交于 2019-11-30 18:16:54
How can I select all checkboxes in recyclerView? I try to do it like this: in Adapter: public void selectAll(){ Log.e("onClickSelectAll","yes"); isSelectedAll=true; notifyDataSetChanged(); } @Override public void onBindViewHolder(ViewHolder holder, int position) { PersonDTO item = dataSet.get(position); holder.tvName.setText(item.getName()); if (!isSelectedAll) holder.cbSelect.setSelected(false); else holder.cbSelect.setSelected(true);} In layout Activity I have a button with onClickListener : private void onClickSelectAll(View view) { getSelectPersonsAdapter().selectAll(); } You made a simple

Select all checkboxes in RecyclerView

梦想的初衷 提交于 2019-11-30 01:55:27
问题 How can I select all checkboxes in recyclerView? I try to do it like this: in Adapter: public void selectAll(){ Log.e("onClickSelectAll","yes"); isSelectedAll=true; notifyDataSetChanged(); } @Override public void onBindViewHolder(ViewHolder holder, int position) { PersonDTO item = dataSet.get(position); holder.tvName.setText(item.getName()); if (!isSelectedAll) holder.cbSelect.setSelected(false); else holder.cbSelect.setSelected(true);} In layout Activity I have a button with onClickListener

Saving checkbox state from Recyclerview

百般思念 提交于 2019-11-29 23:56:51
问题 I have checkbox in my Recyclerview , now i am able to click it and show a snackbar. But can anyone help me to save the state of the checkbox from the recyclerview. I had created an onclicklistener in onBindViewHolder of the recyclerview adapter. private SparseBooleanArray mCheckedItems = new SparseBooleanArray(); @Override public void onBindViewHolder(final RecyclerViewHolder viewHolder, int i) { // get the single element from the main array DisplayImageOptions options = new

Android Nougat: Why do checkboxes on Fragment have incomplete state when selected programmatically (but look fine on Lollipop)

天涯浪子 提交于 2019-11-29 06:19:23
Here is what my settings tab (Fragment) looks like before any selections are made: From the main Fragment the user can make a selection from the Spinner -- looks like the following (after the user has made a choice): When the user makes that selection, choices the user has previously chosen which are saved in the User Prefs are loaded and the appropriate checkboxes are selected. Checkboxes which were shown in first snapshot now look like the following: See, the items which now have associated checkboxes set to pink? Those items turn pink but the check is not shown for some reason on Nougat.

How to set checkbox border color

我是研究僧i 提交于 2019-11-28 22:44:46
The checkbox border is invisible on white background. I played with different color parameters without success. I need black border of box. Yes, there examples to make custom checkbox. In all drawable examples the normal box is visible inside of new shape. And the drawable shape is narrow without text in android:text="" . But why checkbox does not look okay in usual xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layoutBottom1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android