android-checkbox

Align checkbox button to center of view

不问归期 提交于 2019-12-08 11:37:46
问题 I'm trying to create custom checkboxes and I need to align it to the center of the checbox that will have its dynamic size according to the available width. Can someone tell me how I can do this? Is there something missing that I missed? layout <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android

How to add Android Contacts into a listview with a check box [duplicate]

眉间皱痕 提交于 2019-12-08 07:44:54
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I link a checkbox for every contact in populated listview? i m a beginner in android . i want to get the phone contacts and then put them into a listview with a checkbox so that user can select more then one contact and then get the selected contacts. is there any tutorial for that???? thanks 回答1: here is the code to get all contacts with checkbox : ContentResolver cr = getContentResolver(); Cursor cur =

Sharing data between android fragments

馋奶兔 提交于 2019-12-08 06:24:14
I have two fragments. The checkNodesFragment creates dynamically an ArrayList of checkBoxes and then the ReserveNodesFragment should access which of them were checked in checkNodesFragment. What storage method is better to use, so as ReserveNodesFragment can see what checkBoxes where checked? After searching, i found that SharedPreferences is a method to store data permanently. Is SharedPreferences suitable for making data visible through fragments? I am newbie in android, so sorry if the question is obvious. The communication between fragments should be done via Activity . Sharing Data

Sharing data between android fragments

眉间皱痕 提交于 2019-12-08 04:09:29
问题 I have two fragments. The checkNodesFragment creates dynamically an ArrayList of checkBoxes and then the ReserveNodesFragment should access which of them were checked in checkNodesFragment. What storage method is better to use, so as ReserveNodesFragment can see what checkBoxes where checked? After searching, i found that SharedPreferences is a method to store data permanently. Is SharedPreferences suitable for making data visible through fragments? I am newbie in android, so sorry if the

Checkbox item state on menu android

混江龙づ霸主 提交于 2019-12-07 08:46:28
问题 How can I set initial value of checkbox item part of a menu? When I start an Activity I want to set a boolean value saved in Shared Preferences. <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".LoginActivity"> <item android:id="@+id/checkbox" android:title="@string/checkbox" android:orderInCategory="10" android:showAsAction="never" android:visible="true" android:checkable="true" android:checked="true"/> </menu>

How to retain the checkbox state on scroll of gridview in android

瘦欲@ 提交于 2019-12-06 08:24:29
What i am doing :: I have a gridview where i am displaying images I adapter of the gridview has image and a checkbox What is happening :: When i check the checkbox and i scroll the gridview down & when i scrollback , the selected checkbox is unselected Question :: How can i prevent this What changes should i need to make in the code grid_view_image_item.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/flag" android:layout

ListView with Checkboxes Android

[亡魂溺海] 提交于 2019-12-05 08:00:49
问题 The Activity below, ContactMailAdapter.class is my list view adapter containing checkbox. If i want to get the position of a row that has been checked. how can this be done. I have several checkboxes in my list and I can checked multiple checkbox. My logic is that I should store each position that has been checked. then call the data from my arraylist but for now I am not able to get the position of a checked item from my adapter. public class ContactMailAdapter extends BaseAdapter { private

Get checked Listitems from ListView and pass that to another activity

此生再无相见时 提交于 2019-12-05 07:46:42
问题 I'm developing a Android application using ListView . ListView have a one file in each and every ListItem . Here, I have set onItemClick in ListView . So, that if user clicks the ListItem email application gets open and attach the particular file in email. Its for the single File , this gets implemented and working fine. Now I want attach the multiple file in email. i.e. the implementing the CheckBox in each ListItem and checked items have to attached into the Mail. I know its possible

Change checkbox text color when checked

空扰寡人 提交于 2019-12-05 05:40:55
I would like to change color of the text when CheckBox is checked. This is what I have for now: <CheckBox android:id="@+id/checkbox" android:layout_width="20dp" android:layout_height="20dp" android:background="@drawable/states" android:gravity="center_horizontal|center_vertical" android:button="@null" android:text="test/> Checkbox background is normally changed when checkbox is checked. The problem is text. It's always the same color. How can I also change text color when checkbox is checked? This is how I change states for checkbox background (I removed extras because of simplicity): <?xml

Issue with ViewHolder selection

别来无恙 提交于 2019-12-04 06:56:23
问题 I am working in an app in which I handle a ListView which is composite with ViewHolder . In this ViewHolder , I have a CheckBox . Here is my code: private class SettingsArrayAdapter extends ArrayAdapter<Object> { Context context; ArrayList<Object> values; RowSettingsViewHolder vh = null; BigRowSettingsViewHolder bvh = null; @Override public int getItemViewType(int position) { if (values.get(position) instanceof RowContent) { return SMALL_ROW_DESIGN; } else return BIG_ROW_DESIGN; // return