android-checkbox

How to change the color of a CheckBox?

孤街浪徒 提交于 2019-12-17 00:40:54
问题 How do I change the default CheckBox color in Android? By default the CheckBox color is green, and I want to change this color. If it is not possible please tell me how to make a custom CheckBox ? 回答1: If your minSdkVersion is 21+ use android:buttonTint attribute to update the color of a checkbox: <CheckBox ... android:buttonTint="@color/tint_color" /> In projects that use AppCompat library and support Android versions below 21 you can use a compat version of the buttonTint attribute:

Android Checkbox getchecked (CompoundButton.OnCheckedChangeListener (without button click event))

夙愿已清 提交于 2019-12-14 03:28:05
问题 Here is my MainActivity : public class MainActivity extends ActionBarActivity implements CompoundButton.OnCheckedChangeListener { CheckBox cb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getCheckBox(); /* cb = (CheckBox) super.findViewById(R.id.checkbox); cb.setOnCheckedChangeListener(this); */ } public void getCheckBox(){ cb = (CheckBox) super.findViewById(R.id.checkbox); cb

multiple checkboxes checked when one check a one check box

谁说我不能喝 提交于 2019-12-13 07:57:31
问题 I am a New Android Developer and when I click on one check-box multiple check-boxes are checked in multiple rows, I am using a custom adapter, please can anyone help me? My Contact List is following .. public class ContactList extends Activity { ListView lvContacts; List<String> listname; List<String> listnumber; SimpleCursorAdapter adapter; ArrayList<PhoneList> arr; ArrayList<PhoneList> arrnumber; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

click listener + checkbox - on android

久未见 提交于 2019-12-13 04:34:35
问题 public class ChooseFavorites extends Activity implements OnItemClickListener { StationManager st; MyCustomAdapter arr; ListView list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choose_favorites); st = new StationManager(); list = (ListView)findViewById(R.id.stationsList1); arr = new MyCustomAdapter(this, android.R.layout.simple_list_item_multiple_choice, st.getNamesOfStations()); list.setAdapter(arr);

CheckBox Issue in List View With Different Layout For Rows

梦想与她 提交于 2019-12-13 04:21:17
问题 I tried make list view has TextView and CheckBox . It is worked fine but when select CheckBox in row another CheckBox in another row selected too. Example: if I checked first row and scroll down I found another row selected too. This my Adapter Code public class ReadersrListAdapter extends BaseAdapter{ private static final int TYPE_SEPARATOR = 0; private static final int TYPE_ITEM = 1; private static final int TYPE_MAX_COUNT = 2; private Activity activity; private ArrayList<HashMap<String,

Save CheckBox State to SharedPreferences File in Android

孤街醉人 提交于 2019-12-12 23:50:27
问题 I have a couple of check boxes that I need to save so that when the user opens the Application again, they can see the state that they left the application in. I have tried using the preferences but I can't seem to get the result correctly. MainActivity.java package com.example.android.documentchecklist; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android

save checked state of checkbox in multi select listview

白昼怎懂夜的黑 提交于 2019-12-12 19:21:25
问题 I'm new to this multi-select listview. I want to save the checked state of the checkbox in the listview so that if user closes the app and then opens again, the selected checkbox still remain selected. Is there any way to do this. I searched for it and found that it can be done using SharedPreference but I didn't get more information on how to use it. Thanks public class MainActivity extends AppCompatActivity { ListView myList; Button getChoice; String[] listContent = { "January", "February",

How to do put a CheckBox in a ListView?

断了今生、忘了曾经 提交于 2019-12-12 05:26:33
问题 I have a listview with a custon adapter. I the row's layout, I have a text and a checkbox. When I load the listview, I get the data from a database and it has one colunm that determine if the row is cheched or not. When I load the list, its ok, the rows that has to stay checked, stays checkd, and the others no. The problem is: when I unckheck a row ans roll the list down and up, when I return to the start, the row that I had unchecked, returns checked again, how can I resold this problem: The

List item layout containing a CheckBox doesn't work as expected

北慕城南 提交于 2019-12-12 04:51:51
问题 I have a ListView whose layout contains a CheckBox . I want both the CheckBox to be active, and list items themselves to be tappable. It doesn't work. Yes, I know about the typical solution (setting focusable to false on the CheckBox so that it doesn't steal focus). It doesn't help. Here's the layout of my list item: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/rl_container" android:layout_width=

how to store check box value from one activity to another activity

青春壹個敷衍的年華 提交于 2019-12-12 04:45:00
问题 i have two activity with checkboxs in a list and i have to pass each value of checkbox to another activity and make it checked, where i can't use intent to pass that because both activity is not next together. In this case how i will store the values in an array and to retrive in another activity thanks to all, i have done it now and i'm posting it. int i = 0; checkBox = new CheckBox[getItemPR.size()]; Constants.INDEX_TEMP_NEW=new int[getItemPR.size()];// stoing in array[] while (i <