问:
How to add click listener in List View, If ListView have already button in xml?
How to add click listener in List View, If ListView have already button in xml? I want to click on button for open New Activity.

Here is my code.
WashDetail.xml

```<code>      <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#000"
                android:text="Malaber Hill" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_marginLeft="16dp"
                android:layout_marginEnd="20dp"
                android:text="Get Details"
                android:id="@+id/gardetails"
                android:textColor="#FFFFFF"
                android:textSize="20dp"
                android:textStyle="normal"

                />
 </LinearLayout>
</code>```

activity_wash_detail

```<code>    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
       <ListView
         android:layout_width="fill_parent"
         android:id="@+id/ls"
         android:layout_below="@+id/headerlay"
         android:focusable="true"
         android:clickable="true"
         android:duplicateParentState="true"
         android:focusableInTouchMode="true"
         android:layout_height="fill_parent">
        </ListView>
 </LinearLayout>
</code>```

WashDetailActivity.java

```<code>protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wash_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    listView = (ListView) findViewById(ls);
    GetDetails=(Button)findViewById(R.id.gardetails);
    Models = new ArrayList<>();
    Models.add(new WashDetailing(R.drawable.spl, "PP AUTOMATIVES", R.drawable.mahindra, "Authorized"));
    adapter = new WashDetailingAdapter(Models, getApplicationContext());

    listView.setAdapter(adapter);

    listView.setClickable(false);

     gardetails.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v)
         {
            Intent intent= new         Intent(getApplicationContext(),GarageDetailActivity.class);
            startActivity(intent);

        }
    });
}
</code>```

答:
We do it something like this.. But frankly speaking Your question is not clear to me.</p>

```<code>listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int
 position, long id) {
        }
    });
</code>```

Body:
How to add click listener in List View, If ListView have already button in xml? I want to click on button for open New Activity.

Here is my code.
WashDetail.xml

      <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#000"
                android:text="Malaber Hill" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_marginLeft="16dp"
                android:layout_marginEnd="20dp"
                android:text="Get Details"
                android:id="@+id/gardetails"
                android:textColor="#FFFFFF"
                android:textSize="20dp"
                android:textStyle="normal"

                />
 </LinearLayout>

activity_wash_detail

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
       <ListView
         android:layout_width="fill_parent"
         android:id="@+id/ls"
         android:layout_below="@+id/headerlay"
         android:focusable="true"
         android:clickable="true"
         android:duplicateParentState="true"
         android:focusableInTouchMode="true"
         android:layout_height="fill_parent">
        </ListView>
 </LinearLayout>

WashDetailActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wash_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    listView = (ListView) findViewById(ls);
    GetDetails=(Button)findViewById(R.id.gardetails);
    Models = new ArrayList<>();
    Models.add(new WashDetailing(R.drawable.spl, "PP AUTOMATIVES", R.drawable.mahindra, "Authorized"));
    adapter = new WashDetailingAdapter(Models, getApplicationContext());

    listView.setAdapter(adapter);

    listView.setClickable(false);

     gardetails.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v)
         {
            Intent intent= new         Intent(getApplicationContext(),GarageDetailActivity.class);
            startActivity(intent);

        }
    });
}

Body:
We do it something like this.. But frankly speaking Your question is not clear to me.

listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int
 position, long id) {
        }
    });


来源: stackexchange

问:
Disable ValidatesOnDataErrors if IsEnabled property is False WPF
I have a program in MVVM pattern and I have a View which contains some objects, one of them is a Value TextBox which ValidatesOnDataErrors when writing a text in it.

Also I have a Binding to its IsEnabled property which changed on the ViewModel by some conditions I made.

I want be able to eliminate ValidatesOnDataErrors (make it False) when the binding propery of IsEnabled is False, How I can do that?

```<code><StackPanel>
   .....

   <TextBox Text="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" IsEnabled="{Binding isValueFieldEnable}"/>

   .....

</StackPanel>
</code>```

Thank you.

答:
As @Il Vic suggests this validation logic should be implemented in the view model class.

You don't change the ValidatesOnDataErrors property of the binding in the view. Instead, you should make sure that your view model is always in a valid state and return no errors for the data-bound Value property whenever the isValueFieldEnable property returns false.

The binding in the view is always the same. It is your view model that is supposed to define whether the Value property is set to a valid value. And the property should Always considered to be valid when the isValueFieldEnable is false. That's your validation logic. And this should be implemented in your view model class, not in your view.

ContentLicense: CC BY-SA 3.0

Body:
I have a program in MVVM pattern and I have a View which contains some objects, one of them is a Value TextBox which ValidatesOnDataErrors when writing a text in it.

Also I have a Binding to its IsEnabled property which changed on the ViewModel by some conditions I made.

I want be able to eliminate ValidatesOnDataErrors (make it False) when the binding propery of IsEnabled is False, How I can do that?

<StackPanel>
   .....

   <TextBox Text="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" IsEnabled="{Binding isValueFieldEnable}"/>

   .....

</StackPanel>

Thank you.


问:
Trying to center 2 groups of 2 divs each at the middle of a wrapper
I have four divs(all same sizes) i have grouped them into to blocks of 2 with classes blocka both contained in an inner container body-content float all the blocks to the left so when my page width changes,these the blocks(of 2) aligned under each other.
I am trying to get now is that those divs sit right at the middle of the main container.

Everything response well. All i need it the class body content sit at the middle of main while blocka all center themselves in the middle of body-content

.main {
  max-width: 100%;
  margin-left: 240px;
  background-color: ;
}

.body-content {
  background-color: white;
  margin: 0 auto;
  width: 95%;
  padding: 15px;
  border: 1px solid grey;
  height: 100px;
}

.blocka {
  float: left;
  margin: 0 auto;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="main">

  <div class="body-content">
    <div class="blocka">
      <div class="body-content-items">Add All</div>
      <div class="body-content-items">Add All</div>
    </div>
    <div class="blocka">
      <div class="body-content-items">Add All</div>
      <div class="body-content-items">Add All</div>
    </div>
  </div>
</div></code>```

答:
The body-content in this instance is the container.. Anytihng inside body will be flexed as defined..</p>

```<code>.body-content{
    display: flex;
    justify-content: center;
    align-content: center;
    align-items: center;
    flex-direction: column
}

.blocka {
    flex:1
}
</code>```

Body:
I have four divs(all same sizes) i have grouped them into to blocks of 2 with classes blocka both contained in an inner container body-content float all the blocks to the left so when my page width changes,these the blocks(of 2) aligned under each other.
I am trying to get now is that those divs sit right at the middle of the main container.

Everything response well. All i need it the class body content sit at the middle of main while blocka all center themselves in the middle of body-content

.main {
  max-width: 100%;
  margin-left: 240px;
  background-color: ;
}

.body-content {
  background-color: white;
  margin: 0 auto;
  width: 95%;
  padding: 15px;
  border: 1px solid grey;
  height: 100px;
}

.blocka {
  float: left;
  margin: 0 auto;
}

Add All

Add All

Add All

Add All

Body:
The body-content in this instance is the container.. Anytihng inside body will be flexed as defined..

.body-content{
    display: flex;
    justify-content: center;
    align-content: center;
    align-items: center;
    flex-direction: column
}

.blocka {
    flex:1
}


问:
Max number of parametrs to private methods
So there is some kind of a rule for clean code "No more then 3/4 parametrs to method".

Am curious about should I follow this rule for private methods, method which are disigned to use by other function and not called by user. Or I can pass more then 3/4 parametrs to private methods?

答:
Obviously your code is more readable with 3 or 4 arguments rather than 7 or 8, though there are some things you can consider.

If some of the arguments are closely related you can create a placeholder class. For example rather than arguments (int age, String firstName, String lastName) you could use an argument (Person person).

Another case is where the arguments are all of the same type. In this case you can use a varargs and the type signature will look like Type.... varags documentation.

Whilst there is no hard and fast "rule", use your best judgement and think about the readability and maintainability of your code.


问:
Does mootools 1.1 support request method OTHER than get and post?
I'm trying to do the following:

```<code>new Ajax('http://....', {

  method: 'delete'

}).request();
</code>```

The request method when inspected in my php code shows that it is defaulting to POST.

Am I correct to assume that other methods outside of get and post are NOT supported?

ps. I had a quick look in the mootools src file and I can't see any mentions of delete

答:
No, it does not support anything besides 'get' and 'post'.

http://docs111.mootools.net/Remote/XHR.js

ContentLicense: CC BY-SA 2.5

Body:
I'm trying to do the following:

new Ajax('http://....', {

  method: 'delete'

}).request();

The request method when inspected in my php code shows that it is defaulting to POST.

Am I correct to assume that other methods outside of get and post are NOT supported?

ps. I had a quick look in the mootools src file and I can't see any mentions of delete


问:
Create patch based on email and date range in git
1) Assumptions (fake data):

git log

```<code>commit 12ddf89asdfash323jhkfhsadfyas23ifhafdf
Author: Karol Dok <Karol.Dok@gmail.com>
Date:   Mon Mar 31 18:06:44 2014 +0200
TTTT_6222 Coment5.

commit asdf7623rkjadf98723rfaefdsas7d6fa9sass
Author: Tom Tyt <Tom.Tyt@gmail.com>
Date:   Feb Feb 26 7:06:44 2014 +0200
TTTT_4532 Coment4.

commit bs90s7dfgsdfgsfd8g7sd0fg7sd0f98g7sdfgs
Author: Karol Dok <Karol.Dok@gmail.com>
Date:   Wen Feb 10 9:16:44 2014 +0200
TTTT_4532 Coment3.
</code>```

2) Generate patch based on date range 01.02.14-28.02.14 made by "Karol.Dok@gmail.com"

git diff --email='Karol.Dok@gmail.com' --daterange='01.02.14-28.02.14' > patchTest.patch

答:
Generate diff with author and date (start-end) filter:</p>

```<code>git log --since "MAY 1 2017" --until "MAY 31 2017" -p --author="Jack" > diffJackMay.patch
</code>```

Body:
1) Assumptions (fake data):

git log

commit 12ddf89asdfash323jhkfhsadfyas23ifhafdf
Author: Karol Dok <Karol.Dok@gmail.com>
Date:   Mon Mar 31 18:06:44 2014 +0200
TTTT_6222 Coment5.

commit asdf7623rkjadf98723rfaefdsas7d6fa9sass
Author: Tom Tyt <Tom.Tyt@gmail.com>
Date:   Feb Feb 26 7:06:44 2014 +0200
TTTT_4532 Coment4.

commit bs90s7dfgsdfgsfd8g7sd0fg7sd0f98g7sdfgs
Author: Karol Dok <Karol.Dok@gmail.com>
Date:   Wen Feb 10 9:16:44 2014 +0200
TTTT_4532 Coment3.

2) Generate patch based on date range 01.02.14-28.02.14 made by "Karol.Dok@gmail.com"

git diff --email='Karol.Dok@gmail.com' --daterange='01.02.14-28.02.14' > patchTest.patch

Body:
Generate diff with author and date (start-end) filter:

git log --since "MAY 1 2017" --until "MAY 31 2017" -p --author="Jack" > diffJackMay.patch


问:
Multiple pathways for data through a layer in Caffe
I would like to construct a network in Caffe in which the incoming data is split up initially, passes separately through the same set of layers, and is finally recombined using an eltwise layer. After this, all the parts will move as a single blob.

The layer configuration of the part of the network for which the data moves parallely will be identical, except for the learned parameters.

Is there a way to define this network in Caffe without redefining the layers through which the different parts of the data go through multiple times? In other words, is it possible to define a layer once and have multiple pathways for input and output, something like having multiple top and bottom parameters with a mapping between them?

答:
I don't think raw caffe's prototxt format allows for what you are after. But you can get this using caffe.NetSpec() python interface. That is, using python interface to construct the net and write the prototxt file.

```<code>import caffe
from caffe import layers as L
ns = caffe.NetSpec()
ns.data, ns.label = L.Data(ntop=2, name='data', data_param={'source':'/path/to', 'batch_size': 32})
tops = []
for i in xrange(3):
    nm = 'path{}'.format(i)
    top = L.Convolution(ns.data, name=nm, convolution_params={'num_output':32})
    ns.__setattr__(nm, top)
    tops.append(top)
# concat
ns.concat = L.Concat(*tops, name='concat', concat_param={'axis':1})
print '{}'.format(ns.toProto())
</code>```

Body:
I don't think raw caffe's prototxt format allows for what you are after. But you can get this using caffe.NetSpec() python interface. That is, using python interface to construct the net and write the prototxt file.

import caffe
from caffe import layers as L
ns = caffe.NetSpec()
ns.data, ns.label = L.Data(ntop=2, name='data', data_param={'source':'/path/to', 'batch_size': 32})
tops = []
for i in xrange(3):
    nm = 'path{}'.format(i)
    top = L.Convolution(ns.data, name=nm, convolution_params={'num_output':32})
    ns.__setattr__(nm, top)
    tops.append(top)
# concat
ns.concat = L.Concat(*tops, name='concat', concat_param={'axis':1})
print '{}'.format(ns.toProto())


问:
HTML - Writing HTML codes in textarea
I would like to run HTML codes in textarea but it doesn't work. I get data from databese and I'm printing in a variable but codes It looks like it is, not work. How can I run HTML Codes in textarea? My Codes :

```<code>echo "<div id='ilkyaz'> <textarea class='metin_yazisi' id='yep' onkeypress='silyaz(event);'  readonly> $metin  </textarea> </div>";
</code>```

$metin's contain is  Hello

答:
you can use php htmlentities()  which will work for that

```<code>echo "<div id='ilkyaz'> <textarea class='metin_yazisi' id='yep' onkeypress='silyaz(event);'  readonly>".htmlentities($metin)."</textarea> </div>";
</code>```

if you want to remove tag then use strip_tags()

```<code>echo "<div id='ilkyaz'> <textarea class='metin_yazisi' id='yep' onkeypress='silyaz(event);'  readonly>" .strip_tags($metin). " </textarea> </div>";
</code>```

Title: HTML - Writing HTML codes in textarea

Body:
I would like to run HTML codes in textarea but it doesn't work. I get data from databese and I'm printing in a variable but codes It looks like it is, not work. How can I run HTML Codes in textarea? My Codes :

echo "
 <textarea class='metin_yazisi' id='yep' onkeypress='silyaz(event);'  readonly> $metin  </textarea>
";

$metin's contain is  Hello

Body:
you can use php htmlentities()  which will work for that

echo "<div id='ilkyaz'> <textarea class='metin_yazisi' id='yep' onkeypress='silyaz(event);'  readonly>".htmlentities($metin)."</textarea> </div>";

if you want to remove tag then use strip_tags()

echo "<div id='ilkyaz'> <textarea class='metin_yazisi' id='yep' onkeypress='silyaz(event);'  readonly>" .strip_tags($metin). " </textarea> </div>";


问:
How to modify selected UITexFiled value in Array of Textfield
Currently, I created Array of UITextField based on Response from Server in my UI, My response contains three types of response in single API, i.e I get 5 key and Values. Values contains Types like String, Date, Array, based on this when I select the UITextFiled the value must change according to that Particular TextFiled

Here my Sample Code:

```<code>   for (int i=0;i<itemAttributeArray.count;i++){
        UIColor *floatingLabelColor = [UIColor brownColor];
        textField1 = [[JVFloatLabeledTextField alloc] initWithFrame:CGRectMake(16, y, width, height)];
        textField1.delegate = self;
        //Set tag 101
        textField1.tag = 101;
        NSLog(@"textField1.tag - %ld",(long)textField1.tag);
        textField1.text = [[itemAttributeArray valueForKey:@"value"]objectAtIndex:i];
        [self SetTextFieldBorder:textField1];
        textField1.placeholder = [keyArr objectAtIndex:i];

        textField1.font = [UIFont systemFontOfSize:kJVFieldFontSize];
        //            textField1.clearsOnBeginEditing = YES;
        textField1.clearButtonMode = UITextFieldViewModeWhileEditing;

        textField1.floatingLabelFont = [UIFont boldSystemFontOfSize:kJVFieldFloatingLabelFontSize];
        textField1.floatingLabelTextColor = floatingLabelColor;

  //      textField1.translatesAutoresizingMaskIntoConstraints = NO;

        [textField1 resignFirstResponder];

        [_scroll addSubview:textField1];
        [textFields addObject:textField1];
        [textField1 release];

        y += height + margin;

        if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"string"]){
            NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);

        }else if ([[[itemAttributeArray valueForKey:@"type"]
 objectAtIndex:i] isEqualToString:@"date"]){
   NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);
            textField1.tag = 102;
            [textField1 addTarget:self action:@selector(textFieldDidChange_dateChek)
                         forControlEvents:UIControlEventEditingDidBegin];
        }else if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"double"]){
             NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);
        }

-(void)textFieldDidChange_dateChek{
NSLog(@"iam called on first edit");
 _picker_uiView.hidden = false;
[_datePickerView addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
}

 - (void)datePickerValueChanged:(id)sender {
   NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"h:mm a"];

   textField1.text = [dateFormatter
  stringFromDate:_datePickerView.date];
   }
</code>```

When I select the date value is entered in the last object to UITextfield but I selected index is 2nd but values changing on the last element of UITextfield

答:
you are create the textfield in globally, thats the reason you get the last index only. in here assign the tag for each textfield as well as create the instance value.for e.g

```<code> for (int i=0;i<itemAttributeArray.count;i++){
        UIColor *floatingLabelColor = [UIColor brownColor];
       JVFloatLabeledTextField *textField1 = [[JVFloatLabeledTextField alloc] initWithFrame:CGRectMake(16, y, width, height)];
        textField1.delegate = self;
        //Set tag 101
        textField1.tag = 101 + i;
        NSLog(@"textField1.tag - %ld",(long)textField1.tag);
        textField1.text = [[itemAttributeArray valueForKey:@"value"]objectAtIndex:i];
        [self SetTextFieldBorder:textField1];
        textField1.placeholder = [keyArr objectAtIndex:i];

        textField1.font = [UIFont systemFontOfSize:kJVFieldFontSize];
        //            textField1.clearsOnBeginEditing = YES;
        textField1.clearButtonMode = UITextFieldViewModeWhileEditing;

        textField1.floatingLabelFont = [UIFont boldSystemFontOfSize:kJVFieldFloatingLabelFontSize];
        textField1.floatingLabelTextColor = floatingLabelColor;

  //      textField1.translatesAutoresizingMaskIntoConstraints = NO;

        [textField1 resignFirstResponder];

        [_scroll addSubview:textField1];
        [textFields addObject:textField1];
        [textField1 release];

        y += height + margin;

        if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"string"]){
            NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);

        }else if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"date"]){
  NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);

            [textField1 addTarget:self action:@selector(textFieldDidChange_dateChek:)
                         forControlEvents:UIControlEventEditingDidBegin];
        }else if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"double"]){

        }
              }
</code>```

and handle the textfield action

```<code>  -(void)textFieldDidChange_dateChek:(JVFloatLabeledTextField*)textfield{
NSLog(@"iam called on first edit");
 _picker_uiView.hidden = false;

_datePickerView.tag = textfield.tag;
[textfield resignFirstResponder];
[_datePickerView addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
textfield.inputView = _datePickerView;
 }
</code>```

finally assign the value to the textfield as like follow

```<code>- (void)datePickerValueChanged:(UIDatePicker*)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
 //  textField1.tag = 102;
for(id aSubView in [_scroll subviews]){
    if([aSubView isKindOfClass:[JVFloatLabeledTextField class]])
    {
          JVFloatLabeledTextField *textFds=(JVFloatLabeledTextField*)aSubView;
        if (textFds.tag == sender.tag) {
             NSLog(@"dad == %@",[dateFormatter stringFromDate:sender.date]);
            textFds.text = [dateFormatter stringFromDate:sender.date];
            [textFds resignFirstResponder];
            [sender removeFromSuperview];
            break;
        }
    }

        }
}
</code>```

Body:
Currently, I created Array of UITextField based on Response from Server in my UI, My response contains three types of response in single API, i.e I get 5 key and Values. Values contains Types like String, Date, Array, based on this when I select the UITextFiled the value must change according to that Particular TextFiled

Here my Sample Code:

   for (int i=0;i<itemAttributeArray.count;i++){
        UIColor *floatingLabelColor = [UIColor brownColor];
        textField1 = [[JVFloatLabeledTextField alloc] initWithFrame:CGRectMake(16, y, width, height)];
        textField1.delegate = self;
        //Set tag 101
        textField1.tag = 101;
        NSLog(@"textField1.tag - %ld",(long)textField1.tag);
        textField1.text = [[itemAttributeArray valueForKey:@"value"]objectAtIndex:i];
        [self SetTextFieldBorder:textField1];
        textField1.placeholder = [keyArr objectAtIndex:i];

        textField1.font = [UIFont systemFontOfSize:kJVFieldFontSize];
        //            textField1.clearsOnBeginEditing = YES;
        textField1.clearButtonMode = UITextFieldViewModeWhileEditing;

        textField1.floatingLabelFont = [UIFont boldSystemFontOfSize:kJVFieldFloatingLabelFontSize];
        textField1.floatingLabelTextColor = floatingLabelColor;

  //      textField1.translatesAutoresizingMaskIntoConstraints = NO;

        [textField1 resignFirstResponder];

        [_scroll addSubview:textField1];
        [textFields addObject:textField1];
        [textField1 release];

        y += height + margin;

        if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"string"]){
            NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);

        }else if ([[[itemAttributeArray valueForKey:@"type"]
 objectAtIndex:i] isEqualToString:@"date"]){
   NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);
            textField1.tag = 102;
            [textField1 addTarget:self action:@selector(textFieldDidChange_dateChek)
                         forControlEvents:UIControlEventEditingDidBegin];
        }else if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"double"]){
             NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);
        }

-(void)textFieldDidChange_dateChek{
NSLog(@"iam called on first edit");
 _picker_uiView.hidden = false;
[_datePickerView addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
}

 - (void)datePickerValueChanged:(id)sender {
   NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"h:mm a"];

   textField1.text = [dateFormatter
  stringFromDate:_datePickerView.date];
   }

When I select the date value is entered in the last object to UITextfield but I selected index is 2nd but values changing on the last element of UITextfield

Body:
you are create the textfield in globally, thats the reason you get the last index only. in here assign the tag for each textfield as well as create the instance value.for e.g

 for (int i=0;i<itemAttributeArray.count;i++){
        UIColor *floatingLabelColor = [UIColor brownColor];
       JVFloatLabeledTextField *textField1 = [[JVFloatLabeledTextField alloc] initWithFrame:CGRectMake(16, y, width, height)];
        textField1.delegate = self;
        //Set tag 101
        textField1.tag = 101 + i;
        NSLog(@"textField1.tag - %ld",(long)textField1.tag);
        textField1.text = [[itemAttributeArray valueForKey:@"value"]objectAtIndex:i];
        [self SetTextFieldBorder:textField1];
        textField1.placeholder = [keyArr objectAtIndex:i];

        textField1.font = [UIFont systemFontOfSize:kJVFieldFontSize];
        //            textField1.clearsOnBeginEditing = YES;
        textField1.clearButtonMode = UITextFieldViewModeWhileEditing;

        textField1.floatingLabelFont = [UIFont boldSystemFontOfSize:kJVFieldFloatingLabelFontSize];
        textField1.floatingLabelTextColor = floatingLabelColor;

  //      textField1.translatesAutoresizingMaskIntoConstraints = NO;

        [textField1 resignFirstResponder];

        [_scroll addSubview:textField1];
        [textFields addObject:textField1];
        [textField1 release];

        y += height + margin;

        if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"string"]){
            NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);

        }else if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"date"]){
  NSLog(@"type - %@",[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i]);

            [textField1 addTarget:self action:@selector(textFieldDidChange_dateChek:)
                         forControlEvents:UIControlEventEditingDidBegin];
        }else if ([[[itemAttributeArray valueForKey:@"type"] objectAtIndex:i] isEqualToString:@"double"]){

        }
              }

and handle the textfield action

  -(void)textFieldDidChange_dateChek:(JVFloatLabeledTextField*)textfield{
NSLog(@"iam called on first edit");
 _picker_uiView.hidden = false;

_datePickerView.tag = textfield.tag;
[textfield resignFirstResponder];
[_datePickerView addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
textfield.inputView = _datePickerView;
 }

finally assign the value to the textfield as like follow

- (void)datePickerValueChanged:(UIDatePicker*)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
 //  textField1.tag = 102;
for(id aSubView in [_scroll subviews]){
    if([aSubView isKindOfClass:[JVFloatLabeledTextField class]])
    {
          JVFloatLabeledTextField *textFds=(JVFloatLabeledTextField*)aSubView;
        if (textFds.tag == sender.tag) {
             NSLog(@"dad == %@",[dateFormatter stringFromDate:sender.date]);
            textFds.text = [dateFormatter stringFromDate:sender.date];
            [textFds resignFirstResponder];
            [sender removeFromSuperview];
            break;
        }
    }

        }
}


问:
How to make angularjs seo
I am new to angularjs and its seo process, Please can you give me a favour to index all pages in a site.

Prerender pages working good while manual checking with ?_escaped_fragment_= term and also saved in dashboard.

But seo point of view, homepage only got indexed using prerendered html snapshot.Other pages indexed with empty content section, header & footer section only displayed.

In header part, i have used

```<code><base href="/seo3/">
<meta name="description" content={{description}}>
<meta name="robots" content={{robots}}>
<link rel="canonical" href="{{canonical}}" />
<meta name="fragment" content="!">
</code>```

Homepage indexed properly, but other pages not yet. Please give me the solution to index all pages using prerendered snapshots. I think route action not working properly.

答:
use a service to bind data to meta tags

```<code><html ng-app="app">
  <head>
     <base href="/seo3/">
     <meta name="description" content={{metaservice.description()}}>
  </head>

<script>
    var app = angular.module('app',[]);
    app.service('metaservice', function() {
       return {

          description: function(){ return 'your discription'; },
       }
    });

   app.controller('myCtrl',function($scope){
   });
</script>
</code>```

Title: How to make angularjs seo

Body:
I am new to angularjs and its seo process, Please can you give me a favour to index all pages in a site.

Prerender pages working good while manual checking with ?_escaped_fragment_= term and also saved in dashboard.

But seo point of view, homepage only got indexed using prerendered html snapshot.Other pages indexed with empty content section, header & footer section only displayed.

In header part, i have used

<base href="/seo3/">
<meta name="description" content={{description}}>
<meta name="robots" content={{robots}}>
<link rel="canonical" href="{{canonical}}" />
<meta name="fragment" content="!">

Homepage indexed properly, but other pages not yet. Please give me the solution to index all pages using prerendered snapshots. I think route action not working properly.

Body:
use a service to bind data to meta tags

<html ng-app="app">
  <head>
     <base href="/seo3/">
     <meta name="description" content={{metaservice.description()}}>
  </head>

<script>
    var app = angular.module('app',[]);
    app.service('metaservice', function() {
       return {

          description: function(){ return 'your discription'; },
       }
    });

   app.controller('myCtrl',function($scope){
   });
</script>


问:
Instance variable in ruby
```<code>class Test
   def initialize
     @var = "125"
   end
   def testmethod
     puts @var
     puts "accessing me from child class"
   end
 end

class TestExtension < Test

  def method1
    puts @var = "One Hundred and twenty five"
    testmethod()
  end
end

t = Test.new
p = TestExtension.new
p.method1
t.testmethod
</code>```

output:

```<code>One Hundred and twenty five
One Hundred and twenty five
accessing me from child class
125
accessing me from child class
</code>```

My question is that accessing the testmethod() in child class TestExtension results in accessing that value of @var which is being declared in TestExtension class instead of accessing the value which is being declared in Test class . Is it correct ?

答:
It is correct.

As Gareth said, instance variables belong to instances, not classes.

If you want variables to belong to classes, you may use instance variable of class object (err, this term is to complex to write it correctly).

In short, everything in Ruby is an object, including classes. In the following example Base and Derivative are just constants which contain a reference to objects. Those objects represent classes (ta-da!).

Taking this fact into account, we can do the following:

```<code>class Base
  @var = 1

  def self.change(new_value)
    @var = new_value
  end

  def self.to_s
    "#{self.name}, @var = #{@var}"
  end
end

class Derivative < Base; end

Derivative.change(2)

puts Base         # => Base, @var = 1
puts Derivative   # => Derivative, @var = 2
</code>```

Title: Instance variable in ruby

Body:
class Test
   def initialize
     @var = "125"
   end
   def testmethod
     puts @var
     puts "accessing me from child class"
   end
 end

class TestExtension < Test

  def method1
    puts @var = "One Hundred and twenty five"
    testmethod()
  end
end

t = Test.new
p = TestExtension.new
p.method1
t.testmethod

output:

One Hundred and twenty five
One Hundred and twenty five
accessing me from child class
125
accessing me from child class

My question is that accessing the testmethod() in child class TestExtension results in accessing that value of @var which is being declared in TestExtension class instead of accessing the value which is being declared in Test class . Is it correct ?

Body:
It is correct.

As Gareth said, instance variables belong to instances, not classes.

If you want variables to belong to classes, you may use instance variable of class object (err, this term is to complex to write it correctly).

In short, everything in Ruby is an object, including classes. In the following example Base and Derivative are just constants which contain a reference to objects. Those objects represent classes (ta-da!).

Taking this fact into account, we can do the following:

class Base
  @var = 1

  def self.change(new_value)
    @var = new_value
  end

  def self.to_s
    "#{self.name}, @var = #{@var}"
  end
end

class Derivative < Base; end

Derivative.change(2)

puts Base         # => Base, @var = 1
puts Derivative   # => Derivative, @var = 2


问:
Scrollview not scroll inside linearlayout android
Following is the code of layout xml that i have tried to implement, i don't know what is the issue behind it  Can anyone help me?

```<code> <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 android:id="@+id/activity_post"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@color/white"
 android:orientation="vertical"
 android:weightSum="1">
<ScrollView
    android:fillViewport="true"
    android:layout_weight="0.95"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        tools:ignore="NestedWeights"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_weight="0.05"
            tools:ignore="NestedWeights"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="0dp">
            <TextView
                tools:ignore="NestedWeights"
                android:id="@+id/etSearch"
                android:maxLines="1"
                android:layout_weight="0.9"
                android:gravity="center"
                android:padding="@dimen/value_3"
                android:textColor="@color/black"
                android:layout_width="0dp"
                android:textSize="@dimen/font_14"
                android:background="@drawable/bg"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="@string/search_text"/>
            <FrameLayout
                android:background="@drawable/tab_bg_selector"
                android:id="@+id/imgChat"
                tools:ignore="NestedWeights"
                android:layout_gravity="center"
                android:layout_weight="0.1"
                android:layout_margin="@dimen/value_5"
                android:layout_width="0dp"
                android:layout_height="@dimen/value_30">
                <TextView
                    android:gravity="center"
                    android:id="@+id/msgCount"
                    android:textSize="@dimen/font_14"
                    android:textColor="@android:color/white"
                    android:background="@drawable/round"
                    android:layout_gravity="center"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/value_20" />
                <ImageView
                    android:visibility="gone"
                    android:id="@+id/imgMsg"
                    android:src="@drawable/chatt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </FrameLayout>
        </LinearLayout>
        <!--<LinearLayout />-->
        <LinearLayout
            android:layout_weight="0.9"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="0dp">
            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swiperefresh"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:descendantFocusability="blocksDescendants"
                    tools:ignore="NestedWeights"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    >
                    <LinearLayout
                        android:orientation="vertical"
                        android:background="@color/rv_color"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
                        <android.support.v7.widget.RecyclerView
                            tools:ignore="NestedWeights"
                            android:layout_centerInParent="true"
                            android:id="@+id/rvHairList"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:clipToPadding="false" />
                    </LinearLayout>
                    <ProgressBar
                        android:indeterminateTint="@color/user_name"
                        android:id="@+id/main_progress"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"/>
                    <include
                        layout="@layout/error_layout"/>
                </LinearLayout>
            </android.support.v4.widget.SwipeRefreshLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>
<LinearLayout
    android:layout_weight="0.05"
    android:gravity="bottom"
    android:layout_gravity="bottom"
    android:background="@color/white"
    tools:ignore="NestedWeights"
    android:padding="@dimen/value_5"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="horizontal">
    <LinearLayout
        android:id="@+id/llDrawer"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/drawer"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/more"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/llHome"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/imgHome"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/home"/>
    </LinearLayout>
    <FrameLayout
        android:id="@+id/imgFriendRequest"
        tools:ignore="NestedWeights"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:layout_marginRight="@dimen/value_5"
        android:layout_marginLeft="@dimen/value_5"
        android:layout_width="@dimen/value_30"
        android:layout_height="@dimen/value_20">
        <TextView
            android:gravity="center"
            android:id="@+id/friendCount"
            android:textSize="@dimen/font_14"
            android:textColor="@android:color/white"
            android:background="@drawable/round"
            android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView
            android:visibility="gone"
            android:id="@+id/imgFnd"
            android:src="@drawable/add_friend"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>
    <LinearLayout
        android:visibility="gone"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/gestureImg"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/img_thing"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/llNewPost"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/imgGallery"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/gallery"/>
    </LinearLayout>
    <FrameLayout
        android:id="@+id/imgNotification"
        tools:ignore="NestedWeights"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:layout_marginRight="@dimen/value_5"
        android:layout_marginLeft="@dimen/value_5"
        android:layout_width="@dimen/value_30"
        android:layout_height="@dimen/value_20">
        <TextView
            android:gravity="center"
            android:id="@+id/notiCount"
            android:textSize="@dimen/font_14"
            android:textColor="@android:color/white"
            android:background="@drawable/round"
            android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView
            android:visibility="gone"
            android:id="@+id/imgNoti"
            android:src="@drawable/notification"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>
    <LinearLayout
        android:id="@+id/llProfile"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <de.hdodenhof.circleimageview.CircleImageView
            android:layout_gravity="center"
            android:layout_weight="1"
            tools:ignore="NestedWeights"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/imgTimeline"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/loader"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            app:civ_border_color="#FF000000"/>
    </LinearLayout>
</LinearLayout>
</code>```

scrollview not scrolling
i have tried to change height of scrollview and linearlayout of scrollview but not get any solution

答:
You have manage the weight of ScrollView and Layout's and fix
  the bottom LinearLayout height  like Below

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/activity_post"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            tools:ignore="NestedWeights">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.05"
                android:orientation="horizontal"
                tools:ignore="NestedWeights">

                <TextView
                    android:id="@+id/etSearch"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_weight="0.9"
                    android:background="@drawable/bg"
                    android:gravity="center"
                    android:maxLines="1"
                    android:padding="@dimen/value_3"
                    android:text="@string/search_text"
                    android:textColor="@color/black"
                    android:textSize="@dimen/font_14"
                    tools:ignore="NestedWeights" />

                <FrameLayout
                    android:id="@+id/imgChat"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/value_30"
                    android:layout_gravity="center"
                    android:layout_margin="@dimen/value_5"
                    android:layout_weight="0.1"
                    android:background="@drawable/tab_bg_selector"
                    tools:ignore="NestedWeights">

                    <TextView
                        android:id="@+id/msgCount"
                        android:layout_width="wrap_content"
                        android:layout_height="@dimen/value_20"
                        android:layout_gravity="center"
                        android:background="@drawable/round"
                        android:gravity="center"
                        android:textColor="@android:color/white"
                        android:textSize="@dimen/font_14" />

                    <ImageView
                        android:id="@+id/imgMsg"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/chatt"
                        android:visibility="gone" />
                </FrameLayout>
            </LinearLayout>
            <!--<LinearLayout />-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.9"
                android:orientation="vertical">

                <android.support.v4.widget.SwipeRefreshLayout
                    android:id="@+id/swiperefresh"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:descendantFocusability="blocksDescendants"
                        android:orientation="vertical"
                        tools:ignore="NestedWeights">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:background="@color/rv_color"
                            android:orientation="vertical">

                            <android.support.v7.widget.RecyclerView
                                android:id="@+id/rvHairList"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_centerInParent="true"
                                android:clipToPadding="false"
                                tools:ignore="NestedWeights" />
                        </LinearLayout>

                        <ProgressBar
                            android:id="@+id/main_progress"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:indeterminateTint="@color/user_name" />

                        <include layout="@layout/error_layout" />
                    </LinearLayout>
                </android.support.v4.widget.SwipeRefreshLayout>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_gravity="bottom"
        android:background="@color/white"
        android:gravity="bottom"
        android:orientation="horizontal"
        android:padding="@dimen/value_5"
        tools:ignore="NestedWeights">

        <LinearLayout
            android:id="@+id/llDrawer"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:id="@+id/drawer"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/more"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/llHome"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:id="@+id/imgHome"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/home"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <FrameLayout
            android:id="@+id/imgFriendRequest"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_marginRight="@dimen/value_5"
            android:layout_weight="1"
            tools:ignore="NestedWeights">

            <TextView
                android:id="@+id/friendCount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/round"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:textSize="@dimen/font_14" />

            <ImageView
                android:id="@+id/imgFnd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/add_friend"
                android:visibility="gone" />
        </FrameLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:visibility="gone">

            <ImageView
                android:id="@+id/gestureImg"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/img_thing"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/llNewPost"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:id="@+id/imgGallery"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/gallery"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <FrameLayout
            android:id="@+id/imgNotification"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_marginRight="@dimen/value_5"
            android:layout_weight="1"
            tools:ignore="NestedWeights">

            <TextView
                android:id="@+id/notiCount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/round"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:textSize="@dimen/font_14" />

            <ImageView
                android:id="@+id/imgNoti"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/notification"
                android:visibility="gone" />
        </FrameLayout>

        <LinearLayout
            android:id="@+id/llProfile"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/imgTimeline"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:layout_weight="1"
                android:src="@drawable/loader"
                app:civ_border_color="#FF000000"
                tools:ignore="NestedWeights" />
        </LinearLayout>
    </LinearLayout>
</code>```

Body:
Following is the code of layout xml that i have tried to implement, i don't know what is the issue behind it  Can anyone help me?

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 android:id="@+id/activity_post"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@color/white"
 android:orientation="vertical"
 android:weightSum="1">
<ScrollView
    android:fillViewport="true"
    android:layout_weight="0.95"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        tools:ignore="NestedWeights"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_weight="0.05"
            tools:ignore="NestedWeights"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="0dp">
            <TextView
                tools:ignore="NestedWeights"
                android:id="@+id/etSearch"
                android:maxLines="1"
                android:layout_weight="0.9"
                android:gravity="center"
                android:padding="@dimen/value_3"
                android:textColor="@color/black"
                android:layout_width="0dp"
                android:textSize="@dimen/font_14"
                android:background="@drawable/bg"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="@string/search_text"/>
            <FrameLayout
                android:background="@drawable/tab_bg_selector"
                android:id="@+id/imgChat"
                tools:ignore="NestedWeights"
                android:layout_gravity="center"
                android:layout_weight="0.1"
                android:layout_margin="@dimen/value_5"
                android:layout_width="0dp"
                android:layout_height="@dimen/value_30">
                <TextView
                    android:gravity="center"
                    android:id="@+id/msgCount"
                    android:textSize="@dimen/font_14"
                    android:textColor="@android:color/white"
                    android:background="@drawable/round"
                    android:layout_gravity="center"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/value_20" />
                <ImageView
                    android:visibility="gone"
                    android:id="@+id/imgMsg"
                    android:src="@drawable/chatt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </FrameLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_weight="0.9"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="0dp">
            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swiperefresh"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:descendantFocusability="blocksDescendants"
                    tools:ignore="NestedWeights"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    >
                    <LinearLayout
                        android:orientation="vertical"
                        android:background="@color/rv_color"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
                        <android.support.v7.widget.RecyclerView
                            tools:ignore="NestedWeights"
                            android:layout_centerInParent="true"
                            android:id="@+id/rvHairList"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:clipToPadding="false" />
                    </LinearLayout>
                    <ProgressBar
                        android:indeterminateTint="@color/user_name"
                        android:id="@+id/main_progress"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"/>
                    <include
                        layout="@layout/error_layout"/>
                </LinearLayout>
            </android.support.v4.widget.SwipeRefreshLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>
<LinearLayout
    android:layout_weight="0.05"
    android:gravity="bottom"
    android:layout_gravity="bottom"
    android:background="@color/white"
    tools:ignore="NestedWeights"
    android:padding="@dimen/value_5"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="horizontal">
    <LinearLayout
        android:id="@+id/llDrawer"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/drawer"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/more"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/llHome"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/imgHome"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/home"/>
    </LinearLayout>
    <FrameLayout
        android:id="@+id/imgFriendRequest"
        tools:ignore="NestedWeights"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:layout_marginRight="@dimen/value_5"
        android:layout_marginLeft="@dimen/value_5"
        android:layout_width="@dimen/value_30"
        android:layout_height="@dimen/value_20">
        <TextView
            android:gravity="center"
            android:id="@+id/friendCount"
            android:textSize="@dimen/font_14"
            android:textColor="@android:color/white"
            android:background="@drawable/round"
            android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView
            android:visibility="gone"
            android:id="@+id/imgFnd"
            android:src="@drawable/add_friend"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>
    <LinearLayout
        android:visibility="gone"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/gestureImg"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/img_thing"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/llNewPost"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/imgGallery"
            android:layout_gravity="center"
            tools:ignore="NestedWeights"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/gallery"/>
    </LinearLayout>
    <FrameLayout
        android:id="@+id/imgNotification"
        tools:ignore="NestedWeights"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:layout_marginRight="@dimen/value_5"
        android:layout_marginLeft="@dimen/value_5"
        android:layout_width="@dimen/value_30"
        android:layout_height="@dimen/value_20">
        <TextView
            android:gravity="center"
            android:id="@+id/notiCount"
            android:textSize="@dimen/font_14"
            android:textColor="@android:color/white"
            android:background="@drawable/round"
            android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView
            android:visibility="gone"
            android:id="@+id/imgNoti"
            android:src="@drawable/notification"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>
    <LinearLayout
        android:id="@+id/llProfile"
        android:gravity="center"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <de.hdodenhof.circleimageview.CircleImageView
            android:layout_gravity="center"
            android:layout_weight="1"
            tools:ignore="NestedWeights"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/imgTimeline"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:src="@drawable/loader"
            android:layout_marginRight="@dimen/value_5"
            android:layout_marginLeft="@dimen/value_5"
            app:civ_border_color="#FF000000"/>
    </LinearLayout>
</LinearLayout>

scrollview not scrolling
i have tried to change height of scrollview and linearlayout of scrollview but not get any solution

Body:
You have manage the weight of ScrollView and Layout's and fix
  the bottom LinearLayout height  like Below

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/activity_post"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            tools:ignore="NestedWeights">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.05"
                android:orientation="horizontal"
                tools:ignore="NestedWeights">

                <TextView
                    android:id="@+id/etSearch"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_weight="0.9"
                    android:background="@drawable/bg"
                    android:gravity="center"
                    android:maxLines="1"
                    android:padding="@dimen/value_3"
                    android:text="@string/search_text"
                    android:textColor="@color/black"
                    android:textSize="@dimen/font_14"
                    tools:ignore="NestedWeights" />

                <FrameLayout
                    android:id="@+id/imgChat"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/value_30"
                    android:layout_gravity="center"
                    android:layout_margin="@dimen/value_5"
                    android:layout_weight="0.1"
                    android:background="@drawable/tab_bg_selector"
                    tools:ignore="NestedWeights">

                    <TextView
                        android:id="@+id/msgCount"
                        android:layout_width="wrap_content"
                        android:layout_height="@dimen/value_20"
                        android:layout_gravity="center"
                        android:background="@drawable/round"
                        android:gravity="center"
                        android:textColor="@android:color/white"
                        android:textSize="@dimen/font_14" />

                    <ImageView
                        android:id="@+id/imgMsg"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/chatt"
                        android:visibility="gone" />
                </FrameLayout>
            </LinearLayout>
            <!--<LinearLayout />-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.9"
                android:orientation="vertical">

                <android.support.v4.widget.SwipeRefreshLayout
                    android:id="@+id/swiperefresh"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:descendantFocusability="blocksDescendants"
                        android:orientation="vertical"
                        tools:ignore="NestedWeights">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:background="@color/rv_color"
                            android:orientation="vertical">

                            <android.support.v7.widget.RecyclerView
                                android:id="@+id/rvHairList"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_centerInParent="true"
                                android:clipToPadding="false"
                                tools:ignore="NestedWeights" />
                        </LinearLayout>

                        <ProgressBar
                            android:id="@+id/main_progress"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:indeterminateTint="@color/user_name" />

                        <include layout="@layout/error_layout" />
                    </LinearLayout>
                </android.support.v4.widget.SwipeRefreshLayout>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_gravity="bottom"
        android:background="@color/white"
        android:gravity="bottom"
        android:orientation="horizontal"
        android:padding="@dimen/value_5"
        tools:ignore="NestedWeights">

        <LinearLayout
            android:id="@+id/llDrawer"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:id="@+id/drawer"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/more"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/llHome"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:id="@+id/imgHome"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/home"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <FrameLayout
            android:id="@+id/imgFriendRequest"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_marginRight="@dimen/value_5"
            android:layout_weight="1"
            tools:ignore="NestedWeights">

            <TextView
                android:id="@+id/friendCount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/round"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:textSize="@dimen/font_14" />

            <ImageView
                android:id="@+id/imgFnd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/add_friend"
                android:visibility="gone" />
        </FrameLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:visibility="gone">

            <ImageView
                android:id="@+id/gestureImg"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/img_thing"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/llNewPost"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:id="@+id/imgGallery"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:src="@drawable/gallery"
                tools:ignore="NestedWeights" />
        </LinearLayout>

        <FrameLayout
            android:id="@+id/imgNotification"
            android:layout_width="@dimen/value_30"
            android:layout_height="@dimen/value_20"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/value_5"
            android:layout_marginRight="@dimen/value_5"
            android:layout_weight="1"
            tools:ignore="NestedWeights">

            <TextView
                android:id="@+id/notiCount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/round"
                android:gravity="center"
                android:textColor="@android:color/white"
                android:textSize="@dimen/font_14" />

            <ImageView
                android:id="@+id/imgNoti"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/notification"
                android:visibility="gone" />
        </FrameLayout>

        <LinearLayout
            android:id="@+id/llProfile"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/imgTimeline"
                android:layout_width="@dimen/value_30"
                android:layout_height="@dimen/value_20"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/value_5"
                android:layout_marginRight="@dimen/value_5"
                android:layout_weight="1"
                android:src="@drawable/loader"
                app:civ_border_color="#FF000000"
                tools:ignore="NestedWeights" />
        </LinearLayout>
    </LinearLayout>


问:
PivotTable.js OLAP not considering field having more than one value
I am trying to use the PivotTable.JS Script by Nicolas Kruchten and am facing the following problem:

Some of the fields in my data have more than one value. For E.g. in the following entry, there are more than one 'segment' and 'trend':

```<code>{'Segment': ('Lending','Marketplace'), 'Trend': ('Investments', 'Expansion'),  'Month_year': 'Oct 2016', 'Link': 'http://www.geektime.com/2016/10/02/german-credit-startup-smava-bags-34-million-series-c-investment/', 'Title': 'Smava has raised $34 million Series C investment from Runa Capital', 'Country': 'Germany'},
</code>```

Now,

If I pass the Segment as a Tuple ( ), the PivotTable UI just considers the last entry (Marketplace), and ignores all before it (Lending). So it counts 1 for Marketplace and 0 for Lending.

If I pass the segment as a List / Array [ ], the PivotTable UI considers "Lending, Marketplace" as a separate entity all together, instead of counting it separately in both "Lending", as well as "Marketplace".

If I pass the segment as a dictionary { }, the script doesn't work at all.

I cannot break and repeat the entry, with one have "Lending" and another "Marketplace" - as it will lead to a lot of duplicate counts of other fields. E.g. breaking and repeating this entry for both 'segment' and 'trend' will result in four counts for the 'country: Germany', while actually there is only one.

I am stuck at this problem, and need a solution to address it. Any help would be greatly appreciated. TIA

答: Unfortunately, this library does not support multiple values per attribute, so there is no way to do what you're looking for if you are unable to break/repeat the values.</p>

Body:
I am trying to use the PivotTable.JS Script by Nicolas Kruchten and am facing the following problem:

Some of the fields in my data have more than one value. For E.g. in the following entry, there are more than one 'segment' and 'trend':

{'Segment': ('Lending','Marketplace'), 'Trend': ('Investments', 'Expansion'),  'Month_year': 'Oct 2016', 'Link': 'http://www.geektime.com/2016/10/02/german-credit-startup-smava-bags-34-million-series-c-investment/', 'Title': 'Smava has raised $34 million Series C investment from Runa Capital', 'Country': 'Germany'},

Now,

If I pass the Segment as a Tuple ( ), the PivotTable UI just considers the last entry (Marketplace), and ignores all before it (Lending). So it counts 1 for Marketplace and 0 for Lending.

If I pass the segment as a List / Array [ ], the PivotTable UI considers "Lending, Marketplace" as a separate entity all together, instead of counting it separately in both "Lending", as well as "Marketplace".

If I pass the segment as a dictionary { }, the script doesn't work at all.

I cannot break and repeat the entry, with one have "Lending" and another "Marketplace" - as it will lead to a lot of duplicate counts of other fields. E.g. breaking and repeating this entry for both 'segment' and 'trend' will result in four counts for the 'country: Germany', while actually there is only one.

I am stuck at this problem, and need a solution to address it. Any help would be greatly appreciated. TIA


问:
How to process tell-a-friend data?
I'm working on a script that essentially has tell-a-friend functionality, but I'm trying to figure out the best way to capture and process the data.

For example:

Do I display 5 pairs of fields asking for name and email, each pair being $friend_name1/$friend_email1, $friend_name2/$friend_email2, etc, which allows you to email 5 friends at a time?

Do I display one pair and use JavaScript to allow the user to keep adding more friends using the variable naming convention as #1?

Do I display them as suggested in #1 or #2, but then submit an array e.g. $friend_email[]/$friend_name[], etc.

What's the best way to capture the data?

And then what's the best way to process the data?

If you get an array, such as in #3, do you then loop through each $friend_name $_POST? Do you store it in another array? How do you ensure that the correct name/email combination stays together, if for example, the user didn't add a "name" for the third friend?

How do most people do it so they can remain flexible during the capturing and precise during the processing? I'm really looking for logic here, although sample code is much appreciated.

One of the things I'm tracking is who is referring who. For example, if A refers B and B buys something, A will benefit. So accuracy and security are very important to me.

Thanks,
Ryan

答:
These are UI questions, and the answer is whatever UI you think works best for your site. You might have a design where a fixed number of fields fits better, or you might have a demographic where the "add another field" button is too confusing. Either way the code that processes the form doesn't have to be related to how you present the UI.

Regarding making sure your fields stay associated if you name them as an array, specify the indexes yourself rather than using open brackets, and you won't have that problem.

```<code><input type="text" name="name[0]" value="First Friend's Name" />
<input type="text" name="email[0]" value="First Friend's E-mail" />

<input type="text" name="name[1]" value="Second Friend's Name" />
<input type="text" name="email[1]" value="Second Friend's E-mail" />
</code>```

Then in your code,

```<code>foreach ($_POST['email'] as $index => $value) {
    $name = $POST['name'][$index];
    $email = $_POST['email'][$index];
}
</code>```

Within the loop, $name and $email will be from the same set of fields in the form, though they can still be blank.

Title: How to process tell-a-friend data?

Body:
These are UI questions, and the answer is whatever UI you think works best for your site. You might have a design where a fixed number of fields fits better, or you might have a demographic where the "add another field" button is too confusing. Either way the code that processes the form doesn't have to be related to how you present the UI.

Regarding making sure your fields stay associated if you name them as an array, specify the indexes yourself rather than using open brackets, and you won't have that problem.

<input type="text" name="name[0]" value="First Friend's Name" />
<input type="text" name="email[0]" value="First Friend's E-mail" />

<input type="text" name="name[1]" value="Second Friend's Name" />
<input type="text" name="email[1]" value="Second Friend's E-mail" />

Then in your code,

foreach ($_POST['email'] as $index => $value) {
    $name = $POST['name'][$index];
    $email = $_POST['email'][$index];
}

Within the loop, $name and $email will be from the same set of fields in the form, though they can still be blank.


问:
django devserver can't connect
I have a situation where if I run Apache with wsgi (now uninstalled), a test website works, but running the same server with runserver 0.0.0.0:8080 gives ERR_CONNECTION_REFUSED from local or remote (even with the apache2 service stopped).

Edit: I don't think it's Apache, I've reproduced the problem on a clean server with no Apache installed, so unless Apache somehow modified something under source control it's not that

My knowledge of web details is hazy, I don't even know where to troubleshoot this problem - the devserver runs (runserver prints as expected and doesn't give any errors) but never receives a request, I have nothing in iptables.

答:
Sorry for anyone who read this, it would probably have been impossible to solve given my supplied information.

What had actually happened was that I'd been having to modify my wsgi.py script in order to make it happy inside the Apache server, and I'd added a line which said "os.system('/bin/bash --rcfile )" to try and make sure that when running inside apache it got the virtualenv activated.

This line must have been causing some strange problem, another symptom was that I realised when I was running "runserver", it wasn't crashing the the python process was backgrounding itself, where normally it runs inside that console window.

Thanks everyone who asked questions helping me debug!

Title: django devserver can't connect


问:
Will increasing the use of dynamic dispatch reduce compile time?
In swift the compilation time is really slow the amount of code in your project increases. So i was looking for ways to reduce that time. One approach maybe is to use language keywords like final or static to change the way the compiler handles the code in this case using static and dynamic dispatch.

But as far i read is better to avoid runtime overhead reducing dynamic dispatch

So my first doubt is if doing all i can in runtime using more dynamic dispatch reduce compile times at cost of the runtime overhead.

My second doubt is runtime overhead is so bad? that you could sacrifice compile time in order to reduce the overhead?

答:
To the title question:

Compilation time is a function of:

Scanning

Parsing

Symbol Management

Semantic Verification

Type Checking (as @Ron Napier pointed out)

Code path optimizations

Emitting machine code or LLVM-IR

Each one of the steps above will be a function of what techniques are used to accomplish each of the results for the step and the size/complexity of your source file. The is some flexibility in the order and number of steps.

Using dynamic dispatch is a run-time function and worthy of another question.


答:
I would recommend the array. You could do javascript or otherwise, but make sure that the processing end can see how many referrals there are. To ensure the correct e-mail and name stay together, try something like

```<code><input type="text" name="friend_name[0]" />
<input type="text" name="friend_email[0]" />
<input type="text" name="friend_name[1]" />
<input type="text" name="friend_email[1]" />
</code>```

and so on. From there, your PHP script will simply match the array indices in the $_POST var. For instance, if this form was submitted (as above) with some arbitrary data, it would format like this (this is the print_r($_POST); data)

```<code>Array
(
    [friend_name] => Array
        (
            [0] => test_name
            [1] => test_name2
        )

    [friend_email] => Array
        (
            [0] => email@something.com
            [1] => email@two.com
        )

)
</code>```

An idea on looping through these (if you implemented javascript with a potential for an "infinite" number of referrals) would be to use the count(); function. Implementation would look something like this:

```<code>for($i=0;$i<count($_POST['friend_name']);++$i)
{
    if($_POST['friend_email'][$i] == NULL) continue; // Ignore NULL e-mails
    // Process data blah
}
</code>```

Or, if those names where entered out of order, PHP's foreach() feature is very nice and can accomplish the same thing (probably more efficiently for this type of error checking)

```<code>foreach($_POST['friend_name'] as $key => $val)
{
    if($_POST['friend_email'][$key] == NULL) continue; // Ignore NULL e-mails
    // Process $val and $_POST['friend_email'][$key]
}
</code>```

Hope this helps! Good luck!

Dennis M.

Title: How to process tell-a-friend data?

Body:
I'm working on a script that essentially has tell-a-friend functionality, but I'm trying to figure out the best way to capture and process the data.

For example:

Do I display 5 pairs of fields asking for name and email, each pair being $friend_name1/$friend_email1, $friend_name2/$friend_email2, etc, which allows you to email 5 friends at a time?

Do I display one pair and use JavaScript to allow the user to keep adding more friends using the variable naming convention as #1?

Do I display them as suggested in #1 or #2, but then submit an array e.g. $friend_email[]/$friend_name[], etc.

What's the best way to capture the data?

And then what's the best way to process the data?

If you get an array, such as in #3, do you then loop through each $friend_name $_POST? Do you store it in another array? How do you ensure that the correct name/email combination stays together, if for example, the user didn't add a "name" for the third friend?

How do most people do it so they can remain flexible during the capturing and precise during the processing? I'm really looking for logic here, although sample code is much appreciated.

One of the things I'm tracking is who is referring who. For example, if A refers B and B buys something, A will benefit. So accuracy and security are very important to me.

Thanks,
Ryan

Body:
I would recommend the array. You could do javascript or otherwise, but make sure that the processing end can see how many referrals there are. To ensure the correct e-mail and name stay together, try something like

<input type="text" name="friend_name[0]" />
<input type="text" name="friend_email[0]" />
<input type="text" name="friend_name[1]" />
<input type="text" name="friend_email[1]" />

and so on. From there, your PHP script will simply match the array indices in the $_POST var. For instance, if this form was submitted (as above) with some arbitrary data, it would format like this (this is the print_r($_POST); data)

Array
(
    [friend_name] => Array
        (
            [0] => test_name
            [1] => test_name2
        )

    [friend_email] => Array
        (
            [0] => email@something.com
            [1] => email@two.com
        )

)

An idea on looping through these (if you implemented javascript with a potential for an "infinite" number of referrals) would be to use the count(); function. Implementation would look something like this:

for($i=0;$i<count($_POST['friend_name']);++$i)
{
    if($_POST['friend_email'][$i] == NULL) continue; // Ignore NULL e-mails
    // Process data blah
}

Or, if those names where entered out of order, PHP's foreach() feature is very nice and can accomplish the same thing (probably more efficiently for this type of error checking)

foreach($_POST['friend_name'] as $key => $val)
{
    if($_POST['friend_email'][$key] == NULL) continue; // Ignore NULL e-mails
    // Process $val and $_POST['friend_email'][$key]
}

Hope this helps! Good luck!

Dennis M.


问:
Pandas index isin method
I'm having throuble working with the isin method when working with pandas indexes, it always returns False.

```<code>from pandas import DataFrame
df = DataFrame(data=[['a', 1], ['b', 2], ['c', 3]], index=['N01', 'N02', 'N03'])
df.index.isin(['01', '02'])
</code>```

returns

```<code>array([False, False, False], dtype=bool)
</code>```

答:
Use str.contains and pass a regex pattern:

```<code>In[5]: df.index.str.contains('01|02')

Out[5]: array([ True,  True, False], dtype=bool)
</code>```

isin looks for exact matches which is why you get all False array returned

Title: Pandas index isin method

Body:
I'm having throuble working with the isin method when working with pandas indexes, it always returns False.

from pandas import DataFrame
df = DataFrame(data=[['a', 1], ['b', 2], ['c', 3]], index=['N01', 'N02', 'N03'])
df.index.isin(['01', '02'])

returns

array([False, False, False], dtype=bool)

Body:
Use str.contains and pass a regex pattern:

In[5]: df.index.str.contains('01|02')

Out[5]: array([ True,  True, False], dtype=bool)

isin looks for exact matches which is why you get all False array returned


问:
Selecting a range of cells based on a loop variable
I've tried for days to find an answer to this but honestly, it might be a lack of knowledge in the subject that's causing me to not search for the right terms.

I have a spreadsheet with a series of dates between S7:GE7 and rows from 8:96 that have data that need to be locked the next day.

I know my way of selecting the columns is all wrong, and there's probably more wrong too but I can't think of a way to make it right.

```<code>Private Sub Workbook_Open()

Dim i As Range, cell As Range
Set i = Range("S7:GE7")

For Each cell In i
      If (cell.Value < DateValue(Now())) Then
          Range(i + "8:96").Locked = True
      End If
Next cell

End Sub
</code>```

What I'm hoping to achieve with this is a loop that looks through the dates in S7:GE7, and if the date is older than today it locks cells 8:96 in that column.

Any help that can be provided would be much appreciated. Thanks

答:
Try this:</p>

```<code>Private Sub Workbook_Open()

Dim i As Range, cell As Range
Set i = Range("S7:GE7")

For Each cell In i
      If (cell.Value < DateValue(Now())) Then

          cell.Offset(1, 0).Resize(79, 1).Locked = True

        End If
Next cell

End Sub
</code>```

Body:
I've tried for days to find an answer to this but honestly, it might be a lack of knowledge in the subject that's causing me to not search for the right terms.

I have a spreadsheet with a series of dates between S7:GE7 and rows from 8:96 that have data that need to be locked the next day.

I know my way of selecting the columns is all wrong, and there's probably more wrong too but I can't think of a way to make it right.

Private Sub Workbook_Open()

Dim i As Range, cell As Range
Set i = Range("S7:GE7")

For Each cell In i
      If (cell.Value < DateValue(Now())) Then
          Range(i + "8:96").Locked = True
      End If
Next cell

End Sub

What I'm hoping to achieve with this is a loop that looks through the dates in S7:GE7, and if the date is older than today it locks cells 8:96 in that column.

Any help that can be provided would be much appreciated. Thanks

Body:
Try this:

Private Sub Workbook_Open()

Dim i As Range, cell As Range
Set i = Range("S7:GE7")

For Each cell In i
      If (cell.Value < DateValue(Now())) Then

          cell.Offset(1, 0).Resize(79, 1).Locked = True

        End If
Next cell

End Sub