mercredi 27 janvier 2016

Unable to show elements (checkbox or text view) inside layout Android

I want to programmatically add checkboxes inside a LinearLayout who are inside a fragment.

Right now, I'm able to show my first level (textView). I see the space that my checkboxes are supposed to take but nothing appears. Here's my code.

FRAGMENT BACKEND

Context context = activity.getApplicationContext();
List<SousSection> listSousSection = SousSectionService.getSousSectionById(activity, section);
Iterator<SousSection> iterSousSection = listSousSection.iterator();
while (iterSousSection.hasNext()) {
        SousSection sousSection = iterSousSection.next();
        LinearLayout layout = new LinearLayout(context);
        TextView textview = new TextView(context);
        textview.setTag(sousSection.getId());
        textview.setText(sousSection.getTitres().iterator().next()
                .getTitre());
        textview.setGravity(Gravity.CENTER);
        textview.setTextColor(context.getResources()
                .getColor(R.color.black));
        textview.setTextSize(20);
        textview.setTypeface(null, Typeface.BOLD);
        textview.setLayoutParams(new LayoutParams(
                LayoutParams.MATCH_PARENT,   LayoutParams.WRAP_CONTENT));
        layout.addView(textview);

        List<TextSousSection> listTextSousSection = TextSousSectionService.getTextSousSectionBySousSectionId(activity, sousSection);
        Iterator<TextSousSection> iterTextSousSection = listTextSousSection
                .iterator();


        while (iterTextSousSection.hasNext()){
            TextSousSection textSousSection = iterTextSousSection.next();

            CheckBoxWithParam checkbox = new CheckBoxWithParam(
                    context);
            checkbox.setTag(textSousSection.getId());
            checkbox.setChecked(!CheckTextService.isCheckedText(activity, textSousSection));
            //checkbox.setEms(10);
            checkbox.setTextColor(context.getResources().getColor(
                    R.color.black));
            checkbox.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

            if (!textSousSection.getHasParam()) {
                checkbox.setText(textSousSection.getText());
            } else {
                /*do stuff*/
            }

            layout.addView(checkbox);

        }

        parentView.addView(layout);
    }

FRAGMENT FRONTEND

<FrameLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.SectionMasterFragment">

<!-- TODO: Update blank fragment layout -->
<LinearLayout
    android:id="@+id/parentView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:orientation="vertical" >
</LinearLayout>

</FrameLayout>

I also tried with a basic textview, but it stills does not works. Could you help me? thanks




How to enable a checkbox in Gridview only when it's in the Edit mode?

This is how I have my checkbox column currently:

          <asp:TemplateField HeaderText="Hide/Show" ItemStyle-HorizontalAlign="Center" SortExpression="Hide_Show">
                <ItemTemplate>
                    <asp:CheckBox ID="HideShowChk" runat="server" Checked='<%# Bind("Hide_Show") %>' />
                </ItemTemplate>
            </asp:TemplateField>

I have no code in my code behind because it's not necessary. Basically, a user can check or uncheck it, but it won't be reflected in the database unless I actually go into Edit mode, check or uncheck it, and then hit update so that the changes ARE reflected in the database.

Is there a way to have it so that the checkbox is "disabled" or anything of that sort while it's not in edit mode?




Spring JSP Checkboxes on List Object

I am trying to use the <checkboxes> tag on a List Object. But despite reading the mykong tutorial and searching elsewhere, i can't figure out how that is done.

So here is what i want to do: I have a class like

 class Person{

    List<IceCreams> creams;

    }

So now i want to give my User a form where he can choose which IceCreams he likes.

Controller:

@Controller
public class IceCreamController{

@RequestMapping(value="icecream", method=RequestMethod.GET)
public String showPage(Model model){
Person person = repository.getPerson(); //Returns a Person, "creams" is not empty
model.addAttribute("creams", person.getIceCreams();
}

@RequestMapping(value="icecream", method=RequestMethod.POST)
public String showPage( @ModelAttribute("teilnehmer") List<IceCreams> likedCreams, Model model){
//do something with selected iceCreams
}

Now i don't understand how to continue in the JSP. I know i have to use the checkboxes tag, but i do not know what it returns on submit or if i use it correctly.

<form:form>
<form:checkboxes path="creams" items="${creams}"/>
<input type="Submit" value="Submit">
</form:form>

So the question is: What do i write in the JSP and what will be returned to the controller? Thank you!




How to change white background of a checkbox in delphi

I wanted to know that generally the color of the box of a checkbox is white. I want to change the color of the box to some other color for a delphi form. Can someone please help me with it.




Improve performance while selecting element from DOM

I have more than 20,000 records(rows) in my DOM. Each row has one checkbox and and textbox. When I check any checkbox its corresponding textbox should get disabled that's how logic works.

If Checkbox has id '1' then its corresponding textbox's id is 'text_1',the logic is textbox's id ="text_"+checkbox_id

Scenario : If I have list 10000 id's in random order (of checkboxes), I have to disable their corresponding textbox. My logic below

idList.each(function(id){
        $('#text'+id).attr("disabled",true).val("");
      }
    });

This logic takes around 10-12 sec to disabled all the textboxes.

Is there any way to improve performance.




how to select multiple checkboxes in ionic

I am using ionic framework for my app development and want to select multiple checkboxes on click of header checkbox or button.

    <ion-list>
      <ion-checkbox ng-model="filter.color">Colors</ion-checkbox>
      <ion-checkbox ng-model="filter.blue">Red</ion-checkbox>
      <ion-checkbox ng-model="filter.yellow">Yellow</ion-checkbox>
      <ion-checkbox ng-model="filter.pink">Pink</ion-checkbox>

      <ion-checkbox ng-model="filter.number">Number</ion-checkbox>
      <ion-checkbox ng-model="filter.one">1</ion-checkbox>
      <ion-checkbox ng-model="filter.two">2</ion-checkbox>
      <ion-checkbox ng-model="filter.three">3</ion-checkbox>
    </ion-list>

When I click on "Colors", all three three checkboxes should be clicked. And when I uncheck any one of them, "Colors" should be unchecked as well and only the other two should remain.

I achieved this using normal HTML checkboxes and javascript, but a little unsure on how to do it ionic.

Please Help.

Thanks




Get name option and value with multi input checkbox

I have a form with this entry

<input type="checkbox" name="option[repassage]" id="options1" value="10.00"> Repassage 30 mn
<input type="checkbox" name="option[frigo]" id="options2" value="5.00"> Frigo 30 mn

With php i do this to get all the options and i put them in an array but i can not get the right values for 'titre_option' and 'prix_option' !!!

if (isset($_POST['option'])) {
    foreach ( $_POST['option'] as $key => $value ) {
        $_SESSION['option'][] = array('titre_option' => $_POST['option'][$key], 'prix_option' => $_POST['option'][$value]);
    }
}

// What i get
Array
(
    [0] => Array
        (
            [titre_option] => 10.00
            [prix_option] => 
        )

    [1] => Array
        (
            [titre_option] => 5.00
            [prix_option] => 
        )

)

// What i need
Array
(
    [0] => Array
        (
            [titre_option] => repassage
            [prix_option] => 10.00
        )

    [1] => Array
        (
            [titre_option] => frigo
            [prix_option] => 5.00
        )

)

Thank you for your help...