问:
index_not_found_exeception. elassandra

cqlsh> CREATE KEYSPACE twitter WITH REPLICATION = { 'class' :
    'SimpleStrategy', 'replication_factor' : 3 };

cqlsh> CREATE TABLE twitter.user (
       name text,
       attrs map,
       PRIMARY KEY (name)
    );

cqlsh> INSERT INTO twitter.user (name,attrs) VALUES ('bob',{'email':'bob@gmail.com','firstname':'bob'});

答:
you are using the wrong class at the time to create the keyspace it should be 'NetworkTopologyStrategy'

```<code>CREATE KEYSPACE IF NOT EXISTS twitter WITH replication={ 'class':'NetworkTopologyStrategy', 'dc1':'1' };
</code>```

And chenge the name of the datacenter ('dc1') chek the name using nodetool status. It is case sensitive!!!

In my case I solved the problem using DC1 insted of dc1

Title: index_not_found_exeception. elassandra

Body:
you are using the wrong class at the time to create the keyspace it should be 'NetworkTopologyStrategy'

CREATE KEYSPACE IF NOT EXISTS twitter WITH replication={ 'class':'NetworkTopologyStrategy', 'dc1':'1' };

And chenge the name of the datacenter ('dc1') chek the name using nodetool status. It is case sensitive!!!

In my case I solved the problem using DC1 insted of dc1


来源: stackexchange

问:
System.InvalidCastException iterating through Viewdata
System.InvalidCastException iterating through Viewdata

I need to replace the code

```<code>"<%=Html.DropDownList("Part", (SelectList)ViewData["Parts"])%>
</code>```

for dropdown in the following manner for some reason.

```<code> <select> <% foreach (Hexsolve.Data.BusinessObjects.HSPartList item in (IEnumerable<Hexsolve.Data.BusinessObjects.HSPartList>)ViewData["Parts"])
               { %>
            <option value="<%=item.Id %>">
                <%=item.PartName %>

                <%=item.IssueNo %></option>
            <% } %>
        </select>
</code>```

I am getting error converting SelectedList to IEnumerable)

Error: Unable to cast object of type 'System.Web.Mvc.SelectList' to type 'System.Collections.Generic.IEnumerable`1[Hexsolve.Data.BusinessObjects.HSPartList]'.

Is this the right way to iterate through viewdata[]. Please help me out of this.

答:
Sorry my previous answer was incorrect.

I believe the problem is that GetEnumerator returns IEnumerator<SelectListItem>, not IEnumerator<Hexsolve.Data.BusinessObjects.HSPartList> which you are trying to access.

I would suggest something like the following should work:

```<code><% foreach (SelectListItem item in (SelectList)ViewData["Parts"])
{ %>
    <option value="<%= item.Value %>"><%= item.Text %></option>
<% } %>
</code>```

If you need to concatenate PartName and IssueNo in the Text property which it looks like you're trying to do, you could do that while building the select list.

So you might end up with something like:

```<code> public class Part
 {
     public int Id { get; set; }
     public int IssueNo { get; set; }
     public string PartName { get; set; }
 }
</code>```

and

```<code>   var parts = new List<Part>{
             new Part { Id = 1, IssueNo = 1, PartName = "Spanner" },
             new Part { Id = 2, IssueNo = 1, PartName = "Hammer" }
         };

   var selectList = new SelectList(
         parts.Select(p =>
                new { Id = p.Id,
                      Name = p.PartName + " " + p.IssueNo.ToString()}),
         "Id",
         "Name");

   foreach (var item in selectList)
   {
       Console.WriteLine(item.Value);
       Console.WriteLine(item.Text);
   }

   /*
   Output:
   1
   Hammer 1
   2
   Spanner 1
   */
</code>```

Hope that helps!

ContentLicense: CC BY-SA 3.0

Body:
System.InvalidCastException iterating through Viewdata

I need to replace the code

"<%=Html.DropDownList("Part", (SelectList)ViewData["Parts"])%>

for dropdown in the following manner for some reason.

 <select> <% foreach (Hexsolve.Data.BusinessObjects.HSPartList item in (IEnumerable<Hexsolve.Data.BusinessObjects.HSPartList>)ViewData["Parts"])
               { %>
            <option value="<%=item.Id %>">
                <%=item.PartName %>

                <%=item.IssueNo %></option>
            <% } %>
        </select>

I am getting error converting SelectedList to IEnumerable)

Error: Unable to cast object of type 'System.Web.Mvc.SelectList' to type 'System.Collections.Generic.IEnumerable`1[Hexsolve.Data.BusinessObjects.HSPartList]'.

Is this the right way to iterate through viewdata[]. Please help me out of this.

Body:
Sorry my previous answer was incorrect.

I believe the problem is that GetEnumerator returns IEnumerator<SelectListItem>, not IEnumerator<Hexsolve.Data.BusinessObjects.HSPartList> which you are trying to access.

I would suggest something like the following should work:

<% foreach (SelectListItem item in (SelectList)ViewData["Parts"])
{ %>
    <option value="<%= item.Value %>"><%= item.Text %></option>
<% } %>

If you need to concatenate PartName and IssueNo in the Text property which it looks like you're trying to do, you could do that while building the select list.

So you might end up with something like:

 public class Part
 {
     public int Id { get; set; }
     public int IssueNo { get; set; }
     public string PartName { get; set; }
 }

and

   var parts = new List<Part>{
             new Part { Id = 1, IssueNo = 1, PartName = "Spanner" },
             new Part { Id = 2, IssueNo = 1, PartName = "Hammer" }
         };

   var selectList = new SelectList(
         parts.Select(p =>
                new { Id = p.Id,
                      Name = p.PartName + " " + p.IssueNo.ToString()}),
         "Id",
         "Name");

   foreach (var item in selectList)
   {
       Console.WriteLine(item.Value);
       Console.WriteLine(item.Text);
   }

   /*
   Output:
   1
   Hammer 1
   2
   Spanner 1
   */

Hope that helps!

ContentLicense: CC BY-SA 2.5


问:
How to show raw_id value of a ManyToMany relation in the Django admin?
I have an app using raw_id on both ForeignKeyField and ManyToManyField. The admin displays the value of the foreign key on the right of the edit box.

Unfortunatey, it doesn't work with ManyToMany. I've checked the code and I think that it is the normal behavior. However I would like to know if someone has an easy tip to change this behavior?

Thanks in advance

Update: I've tried to subclass the ManyToManyRawIdWidget but I don't know how to say that the raw_id_fields should use my custom widget. formfield_overrides doesn't seem to work with raw_id fields

答:
This works for Django 1.11 and higher

```<code>from django.contrib.admin.sites import site
from django.contrib.admin.widgets import ManyToManyRawIdWidget
from django.core.urlresolvers import reverse, NoReverseMatch
from django.utils.safestring import mark_safe

class VerboseManyToManyRawIdWidget(ManyToManyRawIdWidget):

    def label_and_url_for_value(self, value):
        result = []
        for v in value:
            key = self.rel.get_related_field().name
            try:
                obj = self.rel.model._default_manager.using(self.db).get(**{key: v})
            except (ValueError, self.rel.model.DoesNotExist):
                return '', ''

            try:
                url = reverse(
                    '{}:{}_{}_change'.format(self.admin_site.name, obj._meta.app_label,
                                             obj._meta.object_name.lower()),
                    args=(obj.pk,))
            except NoReverseMatch:
                url = ''  # Admin not registered for target model.

            result.append('<strong><a href="{}">{}</a></strong>'.format(url,  str(obj)))

        return mark_safe('; '.join(result)), ''

class VerboseRawIdManyToManyAdminMixin:
    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name in self.raw_id_fields:
            kwargs.pop('request', None)
            if db_field.rel.__class__.__name__ == 'ManyToManyRel':
                kwargs['widget'] = VerboseManyToManyRawIdWidget(db_field.rel, site)
            return db_field.formfield(**kwargs)
        return super().formfield_for_dbfield(db_field, **kwargs)
</code>```

Also there is Django app for that purpose django-salmonella

Body:
This works for Django 1.11 and higher

from django.contrib.admin.sites import site
from django.contrib.admin.widgets import ManyToManyRawIdWidget
from django.core.urlresolvers import reverse, NoReverseMatch
from django.utils.safestring import mark_safe

class VerboseManyToManyRawIdWidget(ManyToManyRawIdWidget):

    def label_and_url_for_value(self, value):
        result = []
        for v in value:
            key = self.rel.get_related_field().name
            try:
                obj = self.rel.model._default_manager.using(self.db).get(**{key: v})
            except (ValueError, self.rel.model.DoesNotExist):
                return '', ''

            try:
                url = reverse(
                    '{}:{}_{}_change'.format(self.admin_site.name, obj._meta.app_label,
                                             obj._meta.object_name.lower()),
                    args=(obj.pk,))
            except NoReverseMatch:
                url = ''  # Admin not registered for target model.

            result.append('<strong><a href="{}">{}</a></strong>'.format(url,  str(obj)))

        return mark_safe('; '.join(result)), ''

class VerboseRawIdManyToManyAdminMixin:
    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name in self.raw_id_fields:
            kwargs.pop('request', None)
            if db_field.rel.__class__.__name__ == 'ManyToManyRel':
                kwargs['widget'] = VerboseManyToManyRawIdWidget(db_field.rel, site)
            return db_field.formfield(**kwargs)
        return super().formfield_for_dbfield(db_field, **kwargs)

Also there is Django app for that purpose django-salmonella

ContentLicense: CC BY-SA 4.0


问:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
I am trying to implement swipe to delete in RecyclerView. Everything seems to be working fine except drawing  a delete icon below the item that's being swiped.

This is how I am doing it:

```<code>ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {

            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                return false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                int position = viewHolder.getAdapterPosition();

//                Do my stuff
//                }
            }

            @Override
            public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {

                Bitmap icon;
                if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE){

                    View itemView = viewHolder.itemView;
                    float height = (float) itemView.getBottom() - (float) itemView.getTop();
                    float width = height / 3;

                    if(dX > 0){
                        p.setColor(Color.parseColor("#388E3C"));
                        RectF background = new RectF((float) itemView.getLeft(), (float) itemView.getTop(), dX,(float) itemView.getBottom());
                        c.drawRect(background,p);
                        icon = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.ic_delete);
                        RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width);
                        c.drawBitmap(icon,null,icon_dest,p);
                    } else {
                        p.setColor(Color.parseColor("#D32F2F"));
                        RectF background = new RectF((float) itemView.getRight() + dX, (float) itemView.getTop(),(float) itemView.getRight(), (float) itemView.getBottom());
                        c.drawRect(background,p);
                        icon = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.ic_delete);
                        RectF icon_dest = new RectF((float) itemView.getRight() - 2*width ,(float) itemView.getTop() + width,(float) itemView.getRight() - width,(float)itemView.getBottom() - width);
                        c.drawBitmap(icon,null,icon_dest,p);
                    }
                }
                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
            }
        };
        ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
        itemTouchHelper.attachToRecyclerView(mRecyclerView);
</code>```

It is throwing

java.lang.NullPointerException: Attempt to invoke virtual method
  'boolean android.graphics.Bitmap.isRecycled()' on a null object
  reference

Full StackTrace

```<code>09-12 01:28:58.386 26575-26575/com.ozuf.booker E/AndroidRuntime: FATAL EXCEPTION: main
                                                                     Process: com.ozuf.booker, PID: 26575
                                                                     java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
                                                                         at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1281)
                                                                         at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:620)
                                                                         at com.ozuf.booker.fragments.BookFragment$1.onChildDraw(BookFragment.java:149)
                                                                         at android.support.v7.widget.helper.ItemTouchHelper$Callback.onDraw(ItemTouchHelper.java:1956)
                                                                         at android.support.v7.widget.helper.ItemTouchHelper$Callback.access$1400(ItemTouchHelper.java:1356)
                                                                         at android.support.v7.widget.helper.ItemTouchHelper.onDraw(ItemTouchHelper.java:542)
                                                                         at android.support.v7.widget.RecyclerView.onDraw(RecyclerView.java:3373)
                                                                         at android.view.View.draw(View.java:15635)
                                                                         at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:3308)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14568)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273)
                                                                         at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279)
                                                                         at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318)
                                                                         at android.view.ViewRootImpl.draw(ViewRootImpl.java:2575)
                                                                         at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2385)
                                                                         at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2012)
                                                                         at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1073)
                                                                         at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5988)
                                                                         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                                        at android.view.Choreographer.doCallbacks(Chor
</code>```

Line 149 is c.drawBitmap(icon,null,icon_dest,p); I have debugged and I saw that icon is null but I don't understand why it;s null since I've already assigned it a value.

答:
The error is because of the drawable might be a Vector. </p>

```<code>Drawable drawable = ContextCompat.getDrawable(StreamActivity.this,R.drawable.ic_close)
Bitmap icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(icon);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
</code>```

Body:
I am trying to implement swipe to delete in RecyclerView. Everything seems to be working fine except drawing  a delete icon below the item that's being swiped.

This is how I am doing it:

ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {

            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                return false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                int position = viewHolder.getAdapterPosition();

//                Do my stuff
//                }
            }

            @Override
            public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {

                Bitmap icon;
                if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE){

                    View itemView = viewHolder.itemView;
                    float height = (float) itemView.getBottom() - (float) itemView.getTop();
                    float width = height / 3;

                    if(dX > 0){
                        p.setColor(Color.parseColor("#388E3C"));
                        RectF background = new RectF((float) itemView.getLeft(), (float) itemView.getTop(), dX,(float) itemView.getBottom());
                        c.drawRect(background,p);
                        icon = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.ic_delete);
                        RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width);
                        c.drawBitmap(icon,null,icon_dest,p);
                    } else {
                        p.setColor(Color.parseColor("#D32F2F"));
                        RectF background = new RectF((float) itemView.getRight() + dX, (float) itemView.getTop(),(float) itemView.getRight(), (float) itemView.getBottom());
                        c.drawRect(background,p);
                        icon = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.ic_delete);
                        RectF icon_dest = new RectF((float) itemView.getRight() - 2*width ,(float) itemView.getTop() + width,(float) itemView.getRight() - width,(float)itemView.getBottom() - width);
                        c.drawBitmap(icon,null,icon_dest,p);
                    }
                }
                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
            }
        };
        ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
        itemTouchHelper.attachToRecyclerView(mRecyclerView);

It is throwing

java.lang.NullPointerException: Attempt to invoke virtual method
  'boolean android.graphics.Bitmap.isRecycled()' on a null object
  reference

Full StackTrace

09-12 01:28:58.386 26575-26575/com.ozuf.booker E/AndroidRuntime: FATAL EXCEPTION: main
                                                                     Process: com.ozuf.booker, PID: 26575
                                                                     java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
                                                                         at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1281)
                                                                         at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:620)
                                                                         at com.ozuf.booker.fragments.BookFragment$1.onChildDraw(BookFragment.java:149)
                                                                         at android.support.v7.widget.helper.ItemTouchHelper$Callback.onDraw(ItemTouchHelper.java:1956)
                                                                         at android.support.v7.widget.helper.ItemTouchHelper$Callback.access$1400(ItemTouchHelper.java:1356)
                                                                         at android.support.v7.widget.helper.ItemTouchHelper.onDraw(ItemTouchHelper.java:542)
                                                                         at android.support.v7.widget.RecyclerView.onDraw(RecyclerView.java:3373)
                                                                         at android.view.View.draw(View.java:15635)
                                                                         at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:3308)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14568)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3588)
                                                                         at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3567)
                                                                         at android.view.View.updateDisplayListIfDirty(View.java:14528)
                                                                         at android.view.View.getDisplayList(View.java:14590)
                                                                         at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273)
                                                                         at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279)
                                                                         at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318)
                                                                         at android.view.ViewRootImpl.draw(ViewRootImpl.java:2575)
                                                                         at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2385)
                                                                         at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2012)
                                                                         at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1073)
                                                                         at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5988)
                                                                         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                                        at android.view.Choreographer.doCallbacks(Chor

Line 149 is c.drawBitmap(icon,null,icon_dest,p); I have debugged and I saw that icon is null but I don't understand why it;s null since I've already assigned it a value.

Body:
The error is because of the drawable might be a Vector.

Drawable drawable = ContextCompat.getDrawable(StreamActivity.this,R.drawable.ic_close)
Bitmap icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(icon);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);


问:
fitsSystemWindows effect gone for fragments added via FragmentTransaction
I have an Activity with navigation drawer and full-bleed Fragment (with image in the top that must appear behind translucent system bar on Lollipop). While I had an interim solution where the Fragment was inflated by simply having <fragment> tag in Activity's XML, it looked fine.

Then I had to replace <fragment> with <FrameLayout> and perform fragment transactions, and now the fragment does not appear behind the system bar anymore, despite fitsSystemWindows is set to true across all required hierarchy.

I believe there might be some difference between how <fragment> gets inflated within Activity's layout vs on its own. I googled and found some solutions for KitKat, but neither of those worked for me (Lollipop).

activity.xml

```<code><android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                        xmlns:app="http://schemas.android.com/apk/res-auto"
                                        android:id="@+id/drawer_layout"
                                        android:layout_height="match_parent"
                                        android:layout_width="match_parent"
                                        android:fitsSystemWindows="true">

    <FrameLayout
            android:id="@+id/fragment_host"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">

    </FrameLayout>

    <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"/>

</android.support.v4.widget.DrawerLayout>
</code>```

fragment.xml

```<code><android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="224dp"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
...
</code>```

It worked when activity.xml was this way:

```<code><android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                        xmlns:app="http://schemas.android.com/apk/res-auto"
                                        android:id="@+id/drawer_layout"
                                        android:layout_height="match_parent"
                                        android:layout_width="match_parent"
                                        android:fitsSystemWindows="true">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:id="@+id/fragment"
              android:name="com.actinarium.random.ui.home.HomeCardsFragment"
              tools:layout="@layout/fragment_home"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/>

    <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"/>

</android.support.v4.widget.DrawerLayout>
</code>```

答:
My problem was similar to yours: I have a Bottom Bar Navigation which is replacing the content fragments. Now some of the fragments want to draw over the status bar (with CoordinatorLayout, AppBarLayout), others not (with ConstraintLayout, Toolbar).

```<code>ConstraintLayout
  FrameLayout
    [the ViewGroup of your choice]
  BottomNavigationView
</code>```

The suggestion of ianhanniballake to add another CoordinatorLayout  layer is not what I want, so I created a custom FrameLayout which  handles the insets (like he suggested), and after some time I came upon this solution which really is not much code:

activity_main.xml

```<code><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.example.app.WindowInsetsFrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

</android.support.constraint.ConstraintLayout>
</code>```

WindowInsetsFrameLayout.java

```<code>/**
 * FrameLayout which takes care of applying the window insets to child views.
 */
public class WindowInsetsFrameLayout extends FrameLayout {

    public WindowInsetsFrameLayout(Context context) {
        this(context, null);
    }

    public WindowInsetsFrameLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public WindowInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        // Look for replaced fragments and apply the insets again.
        setOnHierarchyChangeListener(new OnHierarchyChangeListener() {
            @Override
            public void onChildViewAdded(View parent, View child) {
                requestApplyInsets();
            }

            @Override
            public void onChildViewRemoved(View parent, View child) {

            }
        });
    }

}
</code>```

Body:
I have an Activity with navigation drawer and full-bleed Fragment (with image in the top that must appear behind translucent system bar on Lollipop). While I had an interim solution where the Fragment was inflated by simply having <fragment> tag in Activity's XML, it looked fine.

Then I had to replace <fragment> with <FrameLayout> and perform fragment transactions, and now the fragment does not appear behind the system bar anymore, despite fitsSystemWindows is set to true across all required hierarchy.

I believe there might be some difference between how <fragment> gets inflated within Activity's layout vs on its own. I googled and found some solutions for KitKat, but neither of those worked for me (Lollipop).

activity.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                        xmlns:app="http://schemas.android.com/apk/res-auto"
                                        android:id="@+id/drawer_layout"
                                        android:layout_height="match_parent"
                                        android:layout_width="match_parent"
                                        android:fitsSystemWindows="true">

    <FrameLayout
            android:id="@+id/fragment_host"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">

    </FrameLayout>

    <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"/>

</android.support.v4.widget.DrawerLayout>

fragment.xml

<android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="224dp"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
...

It worked when activity.xml was this way:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                        xmlns:app="http://schemas.android.com/apk/res-auto"
                                        android:id="@+id/drawer_layout"
                                        android:layout_height="match_parent"
                                        android:layout_width="match_parent"
                                        android:fitsSystemWindows="true">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:id="@+id/fragment"
              android:name="com.actinarium.random.ui.home.HomeCardsFragment"
              tools:layout="@layout/fragment_home"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/>

    <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"/>

</android.support.v4.widget.DrawerLayout>

Body:
My problem was similar to yours: I have a Bottom Bar Navigation which is replacing the content fragments. Now some of the fragments want to draw over the status bar (with CoordinatorLayout, AppBarLayout), others not (with ConstraintLayout, Toolbar).

ConstraintLayout
  FrameLayout
    [the ViewGroup of your choice]
  BottomNavigationView

The suggestion of ianhanniballake to add another CoordinatorLayout  layer is not what I want, so I created a custom FrameLayout which  handles the insets (like he suggested), and after some time I came upon this solution which really is not much code:

activity_main.xml

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.example.app.WindowInsetsFrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

</android.support.constraint.ConstraintLayout>

WindowInsetsFrameLayout.java

/**
 * FrameLayout which takes care of applying the window insets to child views.
 */
public class WindowInsetsFrameLayout extends FrameLayout {

    public WindowInsetsFrameLayout(Context context) {
        this(context, null);
    }

    public WindowInsetsFrameLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public WindowInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        // Look for replaced fragments and apply the insets again.
        setOnHierarchyChangeListener(new OnHierarchyChangeListener() {
            @Override
            public void onChildViewAdded(View parent, View child) {
                requestApplyInsets();
            }

            @Override
            public void onChildViewRemoved(View parent, View child) {

            }
        });
    }

}


问:
Using a photo as
 in CSS
In my school, they said this was the way to go if we used an image as a title with a special font for ex. Now, I'm trying this but I don't really understand

1) why you should do it

2) it doesn't seem to show up unless it is given a specific height.

Can someone show me a better way to do it, while still doing this

 thing?

.title{
  background-image: url(...);
  background-repeat: no-repeat;
  /*it displays nothing now, only when I add a height here*/
}

.titlespan{
  visibility: hidden;
}
```

<pre class="lang-html prettyprint-override"><code><h1 class="title"><span class="titlespan"></span></h1>
</code>```

答:
You should not use h# for image only as these tags has special meaning. E.g. h1 means Title of the page.

And yes, if you have only image as background, then you must set element dimensions (width is set to 100% by default for all block elements).

I would use simple div for that (another option would be  tag that will auto-resize to source dimensions):

#title {
  height: 50px;
  background: url('http://via.placeholder.com/50x50') repeat-x center center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="title"></div></code>```

Title: Using a photo as <h1> in CSS

Body:
You should not use h# for image only as these tags has special meaning. E.g. h1 means Title of the page.

And yes, if you have only image as background, then you must set element dimensions (width is set to 100% by default for all block elements).

I would use simple div for that (another option would be <img> tag that will auto-resize to source dimensions):

#title {
  height: 50px;
  background: url('http://via.placeholder.com/50x50') repeat-x center center;
}

<div id="title"></div>


问:
MS ACCESS replacing wildcard and underscore always stopped working
case:
i need to change the barcode if it contains _A, _B, _C into "".
for example.

image_a into image
, build_b into build

everytime I query

```<code>update table set barcode = replace(barcode,"\_*", "")
</code>```

then it crashes.

an update:

the problem more like if the query contains replace function or instr stopped working. no debug option and simply restarting.

Any help would be appreciated.

答:
a better way would be using mid function

```<code>mid([barcode],1,instr([barcode],"_")-1)
</code>```

and you should always have a where condition when updating: in your case something like WHERE [barcode] Like "*_*"

Body:
case:
i need to change the barcode if it contains _A, _B, _C into "".
for example.

image_a into image
, build_b into build

everytime I query

update table set barcode = replace(barcode,"\_*", "")

then it crashes.

an update:

the problem more like if the query contains replace function or instr stopped working. no debug option and simply restarting.

Any help would be appreciated.

Body:
a better way would be using mid function

mid([barcode],1,instr([barcode],"_")-1)

and you should always have a where condition when updating: in your case something like WHERE [barcode] Like "*_*"


问:
cx_Oracle.DatabaseError: ORA-00933: SQL command not properly ended
I am getting the error cx_Oracle.DatabaseError: ORA-00933: SQL command not properly ended when trying to run the following code. I have used

```<code>import cx_Oracle
ip = '127.0.0.1'
port = 1234
SID = 'abcd'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)

conn = cx_Oracle.connect('username', 'password', dsn_tns)
curs = conn.cursor()
curs.execute('select sysdate from dual;')  # Error is here
curs.close()
conn.close()
</code>```

Running the following works as expected:

```<code>conn = cx_Oracle.connect('username', 'password', dsn_tns)
print (conn.version)
conn.close()
</code>```

答: You don't need the semicolon at the end of the query, maybe it has something to do with that </p>

Body:
I am getting the error cx_Oracle.DatabaseError: ORA-00933: SQL command not properly ended when trying to run the following code. I have used

import cx_Oracle
ip = '127.0.0.1'
port = 1234
SID = 'abcd'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)

conn = cx_Oracle.connect('username', 'password', dsn_tns)
curs = conn.cursor()
curs.execute('select sysdate from dual;')  # Error is here
curs.close()
conn.close()

Running the following works as expected:

conn = cx_Oracle.connect('username', 'password', dsn_tns)
print (conn.version)
conn.close()


问:
Is it possible to combine SharePoint with .net 4 code
We are designing a system.

We would like to use SharePoint webparts which are .net framework 3.5 as the UI. We also have some access to the database which we would like to use EF4 which is framework 4.

Is this possible? Or do we need to put as web service hop in between?

答:
SharePoint webparts come in two types, the ASP.NET ones and the actual SharePoint ones. Most web parts should be built using the ASP.NET base class. Which means you can build a stand alone ASP.NET application with those web parts (dont need sharepoint to host them).

But if you must use sharepoint as the front-end, then yes having a good SOA (web service) is better than trying to merge all the functionality together into sharepoint.


问:
Error while storing Couchbase Lite database in a custom directory while implementing SQLCipher
So,

What i want:

To be able to tell Couchbase Lite (CB Lite) where to store the data and implement SQLCipher encryption on it.

What is my problem:

Even though i have the encryption working on the default directory, as soon as i tell the Manager to use a custom directory it throws an exception when trying to create the database:
Message:

"Error 8, 1032 (attempt to write a readonly database) executing sql '     CREATE INDEX docs_docid ON docs(docid)'"

Source:

"Couchbase.Lite.Storage.SQLCipher"

StackTrace:

"at Couchbase.Lite.Storage.SQLCipher.SqlitePCLRawStorageEngine.ExecSQL (System.String sql, SQLitePCL.sqlite3 db, System.Object[] paramArgs) [0x00079] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/StorageEngines/SQLiteCommon/storage.sqlite.common/src/DatabaseUpgraderFactory_Upgraders.cs:249 \n  at Couchbase.Lite.Storage.SQLCipher.SqlitePCLRawStorageEngine.ExecSQL (System.String sql, System.Object[] paramArgs) <0xd70821f8 + 0x0005f> in <223c4357c0d44faaaa01c387793a30cc>:0 \n  at Couchbase.Lite.Storage.SQLCipher.SqlitePCLRawStorageEngine.Open (System.String path, System.Boolean readOnly, System.String schema, Couchbase.Lite.Store.SymmetricKey encryptionKey) [0x00065] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/StorageEngines/SQLiteCommon/storage.sqlite.common/src/DatabaseUpgraderFactory.cs:87 "

Now, The strange thing is that when running my code on the emulator, it throws no exception. The problem comes only when running my code on a real device (Lenovo TAB 2A Series, Android 5.0.1).

Note: Even though the exception is thrown the custom folder is created, and the couchbase lite folder as well, but inside it is only to be found a file called db.sqlite3. Normally three files and a folder are created:

Note 2: I had added the WRITE_EXTERNAL_STORAGE permission to the Android Manifest.

The code that runs with no problem:

```<code>public async Task<Database> OpenDatabaseOnEncryptedWayAsync(string encryptionPassword)
    {
        Database encryptedDatabase = null;

        try
        {
            SymmetricKey Key;
            DatabaseOptions options = new DatabaseOptions();
            await Task.Run(() =>
            {
                Key = new SymmetricKey(encryptionPassword);
                options.EncryptionKey = Key;
                options.Create = true;
                options.StorageType = StorageEngineTypes.SQLite;
            });

            // Database stored in default directory
            encryptedDatabase = Manager.SharedInstance.OpenDatabase(database, options);
        }
        catch (CouchbaseLiteException e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Error while creating encrypted database: {0}", e));
            Console.WriteLine("Encryption Message: {0}", e);
        }
        catch (Exception e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Unhandled Exception on OpenDatabaseOnEncryptedWayAsync method: {0}", e));
            Console.WriteLine("Unhandled Exception Message: {0}", e);
        }

        App.SettingsViewModel.isDatabaseOpen = encryptedDatabase != null;

        return encryptedDatabase;
    }
</code>```

The code that throws the (CouchbaseLite)exception:

```<code>    public async Task<Database> OpenDatabaseOnEncryptedWayAsync(string encryptionPassword)
    {
        Database encryptedDatabase = null;

        try
        {
            SymmetricKey Key;
            DatabaseOptions options = new DatabaseOptions();
            await Task.Run(() =>
            {
                Key = new SymmetricKey(encryptionPassword);
                options.EncryptionKey = Key;
                options.Create = true;
                options.StorageType = StorageEngineTypes.SQLite;
            });

            // Custom directory
            var path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).Path;
            var dir = Directory.CreateDirectory(path);
            Manager manager = new Manager(dir, Manager.DefaultOptions);
            encryptedDatabase = manager.GetDatabase(database);
        }
        catch (CouchbaseLiteException e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Error while creating encrypted database: {0}", e));
            Console.WriteLine("Encryption Message: {0}", e);
        }
        catch (Exception e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Unhandled Exception on OpenDatabaseOnEncryptedWayAsync method: {0}", e));
            Console.WriteLine("Unhandled Exception Message: {0}", e);
        }

        App.SettingsViewModel.isDatabaseOpen = encryptedDatabase != null;

        return encryptedDatabase;
    }
</code>```

So, does anybody out there knows how to deal with this issue? Thanks in advance :)

答:
Comming back to the topic, i found a very simple error in the code that throws the (CouchbaseLite)Exception. I share it in case anyone reading this falls in the same error:

I am creating the directory and then the manager using the new path, but i never assign the DatabaseOptions to the newly created Manager

```<code>SymmetricKey Key;
DatabaseOptions options = new DatabaseOptions();
await Task.Run(() =>
{
    Key = new SymmetricKey(encryptionPassword);
    options.EncryptionKey = Key;
    options.Create = true;
    options.StorageType = StorageEngineTypes.SQLite;
});
var path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).Path;
var dir = Directory.CreateDirectory(path);
Manager manager = new Manager(dir, Manager.DefaultOptions);
encryptedDatabase = manager.GetDatabase(database);
</code>```

So, all we have to do is to change the code to read

```<code>encryptedDatabase = manager.OpenDatabase(database, options);
</code>```

And that's it!

Body:
So,

What i want:

To be able to tell Couchbase Lite (CB Lite) where to store the data and implement SQLCipher encryption on it.

What is my problem:

Even though i have the encryption working on the default directory, as soon as i tell the Manager to use a custom directory it throws an exception when trying to create the database:
Message:

"Error 8, 1032 (attempt to write a readonly database) executing sql '     CREATE INDEX docs_docid ON docs(docid)'"

Source:

"Couchbase.Lite.Storage.SQLCipher"

StackTrace:

"at Couchbase.Lite.Storage.SQLCipher.SqlitePCLRawStorageEngine.ExecSQL (System.String sql, SQLitePCL.sqlite3 db, System.Object[] paramArgs) [0x00079] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/StorageEngines/SQLiteCommon/storage.sqlite.common/src/DatabaseUpgraderFactory_Upgraders.cs:249 \n  at Couchbase.Lite.Storage.SQLCipher.SqlitePCLRawStorageEngine.ExecSQL (System.String sql, System.Object[] paramArgs) <0xd70821f8 + 0x0005f> in <223c4357c0d44faaaa01c387793a30cc>:0 \n  at Couchbase.Lite.Storage.SQLCipher.SqlitePCLRawStorageEngine.Open (System.String path, System.Boolean readOnly, System.String schema, Couchbase.Lite.Store.SymmetricKey encryptionKey) [0x00065] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build@2/1.4/Android/couchbase-lite-net/src/StorageEngines/SQLiteCommon/storage.sqlite.common/src/DatabaseUpgraderFactory.cs:87 "

Now, The strange thing is that when running my code on the emulator, it throws no exception. The problem comes only when running my code on a real device (Lenovo TAB 2A Series, Android 5.0.1).

Note: Even though the exception is thrown the custom folder is created, and the couchbase lite folder as well, but inside it is only to be found a file called db.sqlite3. Normally three files and a folder are created:

Note 2: I had added the WRITE_EXTERNAL_STORAGE permission to the Android Manifest.

The code that runs with no problem:

public async Task<Database> OpenDatabaseOnEncryptedWayAsync(string encryptionPassword)
    {
        Database encryptedDatabase = null;

        try
        {
            SymmetricKey Key;
            DatabaseOptions options = new DatabaseOptions();
            await Task.Run(() =>
            {
                Key = new SymmetricKey(encryptionPassword);
                options.EncryptionKey = Key;
                options.Create = true;
                options.StorageType = StorageEngineTypes.SQLite;
            });

            // Database stored in default directory
            encryptedDatabase = Manager.SharedInstance.OpenDatabase(database, options);
        }
        catch (CouchbaseLiteException e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Error while creating encrypted database: {0}", e));
            Console.WriteLine("Encryption Message: {0}", e);
        }
        catch (Exception e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Unhandled Exception on OpenDatabaseOnEncryptedWayAsync method: {0}", e));
            Console.WriteLine("Unhandled Exception Message: {0}", e);
        }

        App.SettingsViewModel.isDatabaseOpen = encryptedDatabase != null;

        return encryptedDatabase;
    }

The code that throws the (CouchbaseLite)exception:

    public async Task<Database> OpenDatabaseOnEncryptedWayAsync(string encryptionPassword)
    {
        Database encryptedDatabase = null;

        try
        {
            SymmetricKey Key;
            DatabaseOptions options = new DatabaseOptions();
            await Task.Run(() =>
            {
                Key = new SymmetricKey(encryptionPassword);
                options.EncryptionKey = Key;
                options.Create = true;
                options.StorageType = StorageEngineTypes.SQLite;
            });

            // Custom directory
            var path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).Path;
            var dir = Directory.CreateDirectory(path);
            Manager manager = new Manager(dir, Manager.DefaultOptions);
            encryptedDatabase = manager.GetDatabase(database);
        }
        catch (CouchbaseLiteException e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Error while creating encrypted database: {0}", e));
            Console.WriteLine("Encryption Message: {0}", e);
        }
        catch (Exception e)
        {
            LogWriterMethod.TryWriteLog(String.Format("Unhandled Exception on OpenDatabaseOnEncryptedWayAsync method: {0}", e));
            Console.WriteLine("Unhandled Exception Message: {0}", e);
        }

        App.SettingsViewModel.isDatabaseOpen = encryptedDatabase != null;

        return encryptedDatabase;
    }

So, does anybody out there knows how to deal with this issue? Thanks in advance :)

Body:
Comming back to the topic, i found a very simple error in the code that throws the (CouchbaseLite)Exception. I share it in case anyone reading this falls in the same error:

I am creating the directory and then the manager using the new path, but i never assign the DatabaseOptions to the newly created Manager

SymmetricKey Key;
DatabaseOptions options = new DatabaseOptions();
await Task.Run(() =>
{
    Key = new SymmetricKey(encryptionPassword);
    options.EncryptionKey = Key;
    options.Create = true;
    options.StorageType = StorageEngineTypes.SQLite;
});
var path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).Path;
var dir = Directory.CreateDirectory(path);
Manager manager = new Manager(dir, Manager.DefaultOptions);
encryptedDatabase = manager.GetDatabase(database);

So, all we have to do is to change the code to read

encryptedDatabase = manager.OpenDatabase(database, options);

And that's it!


问:
Bootstrap 4 navbar doesn't show Toggler
I created an Angular 5 application and included Bootstrap 4 via index.html. I made a basic navbar component and tried to include it in my app. But in responsive mode, I am not able to see the toggler, it appears white but when inspecting I can see it as well as clicking on it also shows the menu. Why is it not being displayed properly?

I am using a simple navbar like below:

```<code><nav class="navbar navbar-expand-lg shift">
  <a class="navbar-brand" href="#">
    <img src="logo.png" alt="Brand Logo" />
  </a>
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown"
    aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarNavDropdown">
    <ul class="nav nav-pills ml-auto">
      <li class="nav-item">
        <a class="nav-link" href="#">Features</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Exams</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Contact</a>
      </li>
    </ul>
  </div>
</nav>
</code>```

Here is my fiddle: jsfiddle

答:
You are missing the color theme in your nav element (navbar-light):

```<code><nav class="navbar navbar-expand-lg shift navbar-light">
</code>```

Fiddle here

Title: Bootstrap 4 navbar doesn't show Toggler

Body:
I created an Angular 5 application and included Bootstrap 4 via index.html. I made a basic navbar component and tried to include it in my app. But in responsive mode, I am not able to see the toggler, it appears white but when inspecting I can see it as well as clicking on it also shows the menu. Why is it not being displayed properly?

I am using a simple navbar like below:

  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown"
    aria-expanded="false" aria-label="Toggle navigation">

  </button>

        Features

        Exams

        Contact

Here is my fiddle: jsfiddle

Body:
You are missing the color theme in your nav element (navbar-light):

<nav class="navbar navbar-expand-lg shift navbar-light">

Fiddle here


问:
Background color for the last second row of the table
I want red color as the background for the last second row of the table.

But it is not changing.

I tried:

```<code>    $i = 0;
    $total = 0;
    $stmttr = $user_home->runQuery("SELECT * FROM invoice WHERE BRN = :inv"); // Your query
    $stmttr->bindParam(':inv',$irn);
    $allRows = $stmttr->rowCount(); // Count Total rows available in result
    $tri = 0; // initiate variable to check <tr> status
        while($rowc)
        {
            extract($rowc);
            $i++;

?>

    <tr  <?php if(++$tri==$allRows) { ?> style="background-color: red;"<?php } ?>   >
      <td style="border-top:none !important; border-bottom:none !important;">
</code>```

See the full code:

```<code><?php
    $i = 0;
    $total = 0;
    $stmttr = $user_home->runQuery("SELECT * FROM invoice WHERE BRN = :inv"); // Your query
    $stmttr->bindParam(':inv',$irn);
    $allRows = $stmttr->rowCount(); // Count Total rows available in result
    $tri = 0; // initiate variable to check <tr> status
        while($rowc)
        {
            extract($rowc);
            $i++;

?>

    <tr  <?php if(++$tri==$allRows) { ?> style="background-color: red;"<?php } ?>   >
      <td style="border-top:none !important; border-bottom:none !important;">
        <?php echo $i; ?>
      </td>
      <td style="border-top:none !important; border-bottom:none !important;">
        <?php
        $itm = $IRN;
        $stmti = $user_home->runQuery('SELECT * FROM item WHERE IRN = :iinv ');
        $stmti->bindParam(':iinv',$itm);
        $stmti->execute();
        $rowci = $stmti->fetch(PDO::FETCH_ASSOC);
        echo $rowci['Name'];
        $srv = $SRN;
        $stmts = $user_home->runQuery('SELECT * FROM service WHERE SRN = :sinv ');
        $stmts->bindParam(':sinv',$srv);
        $stmts->execute();
        $rowcs = $stmts->fetch(PDO::FETCH_ASSOC);
        ?>
         (<?php echo $rowcs['Name']; ?>)
      </td>
      <td style="border-top:none !important; border-bottom:none !important;">
        <?php echo $Quantity; ?>
      </td>
      <td style="border-top:none !important; border-bottom:none !important;">
        <?php echo $Amnt; ?>
      </td>
    </tr>
</code>```

答:
Maybe you have a problem on your loop. What are on variable $rowc?

Maybe you should add
 before the first
 and
 after
the last
?

And CSS should be in a css file, better practice!

I don't have your DB, but this code is working, if it's what you want.

```<code><?php
$tri = 0;
$nbrows=10;

 ?>
<table>
<?php
while ($tri<$nbrows) {  ?>
    <tr <?php if(++$tri==$nbrows) { echo "style=\"background-color: red;\"";} ?> >
     <td style="border-top:none !important; border-bottom:none !important;">Your content </td>
      <td style="border-top:none !important; border-bottom:none !important;">Content 2 </td>
    </tr>
<?php
}
 ?>
</table>
</code>```

Body:
I want red color as the background for the last second row of the table.

But it is not changing.

I tried:

    $i = 0;
    $total = 0;
    $stmttr = $user_home->runQuery("SELECT * FROM invoice WHERE BRN = :inv"); // Your query
    $stmttr->bindParam(':inv',$irn);
    $allRows = $stmttr->rowCount(); // Count Total rows available in result
    $tri = 0; // initiate variable to check
 status
        while($rowc)
        {
            extract($rowc);
            $i++;

?>

    <tr  <?php if(++$tri==$allRows) { ?> style="background-color: red;"<?php } ?>   >

See the full code:

<?php
    $i = 0;
    $total = 0;
    $stmttr = $user_home->runQuery("SELECT * FROM invoice WHERE BRN = :inv"); // Your query
    $stmttr->bindParam(':inv',$irn);
    $allRows = $stmttr->rowCount(); // Count Total rows available in result
    $tri = 0; // initiate variable to check
 status
        while($rowc)
        {
            extract($rowc);
            $i++;

?>

    <tr  <?php if(++$tri==$allRows) { ?> style="background-color: red;"<?php } ?>   >

        <?php echo $i; ?>

        <?php
        $itm = $IRN;
        $stmti = $user_home->runQuery('SELECT * FROM item WHERE IRN = :iinv ');
        $stmti->bindParam(':iinv',$itm);
        $stmti->execute();
        $rowci = $stmti->fetch(PDO::FETCH_ASSOC);
        echo $rowci['Name'];
        $srv = $SRN;
        $stmts = $user_home->runQuery('SELECT * FROM service WHERE SRN = :sinv ');
        $stmts->bindParam(':sinv',$srv);
        $stmts->execute();
        $rowcs = $stmts->fetch(PDO::FETCH_ASSOC);
        ?>
         (<?php echo $rowcs['Name']; ?>)

        <?php echo $Quantity; ?>

        <?php echo $Amnt; ?>

Body:
Maybe you have a problem on your loop. What are on variable $rowc?

Maybe you should add <table> before the first <tr> and </table> after
the last </tr>?

And CSS should be in a css file, better practice!

I don't have your DB, but this code is working, if it's what you want.

<?php
$tri = 0;
$nbrows=10;

 ?>
<table>
<?php
while ($tri<$nbrows) {  ?>
    <tr <?php if(++$tri==$nbrows) { echo "style=\"background-color: red;\"";} ?> >
     <td style="border-top:none !important; border-bottom:none !important;">Your content </td>
      <td style="border-top:none !important; border-bottom:none !important;">Content 2 </td>
    </tr>
<?php
}
 ?>
</table>


问:
How to display 2 labels dynamically with different color?

See in Image, in that message "I still look back on that expe...." and after that one count value is there i.e (7) .

Here, message color is blue and count value i.e (7) is in green color.

My question is that, how to adjust both labels dynamically with different length and different color like example shown in image.

答:
You can use NSAttributedString like in this example:

```<code>NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"I still look back on that expe.... (7)"];
[string setColorForText:@"I still look back on that expe...." withColor:[UIColor blueColor]];
[string setColorForText:@"(7)" withColor:[UIColor greenColor]];
mylabel.attributedText = string;
</code>```

Or you can use the constraints in storyboard.
It is simple, you must use the Content Hugging Priority and Content Compression Resistance Priority values to reduce the first label to attach to the other label.

If you want I can explain you in detail how to do it.

EDIT:

You can try this code:

```<code>NSString *firstPart = @"I still look back on that expe....";
NSString *secondPart = @"(7)";

NSAttributedString *firstAttrStr  = [[NSAttributedString alloc] initWithString:firstPart attributes:@{ NSForegroundColorAttributeName : [UIColor blueColor] }];
NSAttributedString *secondAttrStr = [[NSAttributedString alloc] initWithString:secondPart attributes:@{ NSForegroundColorAttributeName : [UIColor greenColor] }];

NSMutableAttributedString* result = [firstAttrStr mutableCopy];
[result appendAttributedString:secondAttrStr];

self.label.attributedText = result;
</code>```

To add the images you can use NSTextAttachment.

Body:
You can use NSAttributedString like in this example:

NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"I still look back on that expe.... (7)"];
[string setColorForText:@"I still look back on that expe...." withColor:[UIColor blueColor]];
[string setColorForText:@"(7)" withColor:[UIColor greenColor]];
mylabel.attributedText = string;

Or you can use the constraints in storyboard.
It is simple, you must use the Content Hugging Priority and Content Compression Resistance Priority values to reduce the first label to attach to the other label.

If you want I can explain you in detail how to do it.

EDIT:

You can try this code:

NSString *firstPart = @"I still look back on that expe....";
NSString *secondPart = @"(7)";

NSAttributedString *firstAttrStr  = [[NSAttributedString alloc] initWithString:firstPart attributes:@{ NSForegroundColorAttributeName : [UIColor blueColor] }];
NSAttributedString *secondAttrStr = [[NSAttributedString alloc] initWithString:secondPart attributes:@{ NSForegroundColorAttributeName : [UIColor greenColor] }];

NSMutableAttributedString* result = [firstAttrStr mutableCopy];
[result appendAttributedString:secondAttrStr];

self.label.attributedText = result;

To add the images you can use NSTextAttachment.


问:
layout problem in android
I am creating fixed header and fixed footer for RelativeLayout. In the center part I am adding array of WebView when it come ScrollView it hide header and footer.

How can I avoid that?

This is my layout file:

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainrelativelayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:id="@+id/mainlinear2"
        android:layout_alignParentTop="true"
        android:orientation="vertical">
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="15dip"
            android:orientation="horizontal"
            android:id="@+id/linear5">
            <TextView android:text=" "
                android:id="@+id/txtwebservice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/gray2"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="6dip"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView08"
                android:layout_gravity="center"
                android:background="@drawable/line"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"></ImageView>
        </LinearLayout>
        <LinearLayout mlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView android:paddingRight="75dip"
                android:paddingLeft="20dip"
                android:text="Index"
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textStyle="bold"></TextView>
            <TextView android:paddingRight="60dip"
                android:text="Last"
                android:id="@+id/TextView02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textStyle="bold"></TextView>
            <TextView android:text="Change"
                android:id="@+id/TextView03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textStyle="bold"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="6dip"
            android:orientation="horizontal">
            <ImageView
                android:id="@+id/ImageView08"
                android:layout_gravity="center"
                android:background="@drawable/line"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"></ImageView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear2"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView05"
                android:paddingTop="5dip"
                android:layout_gravity="center"
                android:background="@drawable/down"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView
                android:paddingRight="30dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView
                android:paddingRight="55dip"
                android:text=""
                android:id="@+id/txtlast0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/red1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear3"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView02"
                android:layout_gravity="center"
                android:background="@drawable/up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView
                android:paddingRight="46dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:paddingRight="64dip"
                android:text=""
                android:id="@+id/txtlast1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/green1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear4"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView03"
                android:layout_gravity="center"
                android:background="@drawable/up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView android:paddingRight="69dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:paddingRight="67dip"
                android:text=""
                android:id="@+id/txtlast2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/green1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear4"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView04"
                android:layout_gravity="center"
                android:background="@drawable/up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView android:paddingRight="61dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:paddingRight="65dip"
                android:text=""
                android:id="@+id/txtlast3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/green1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="4dip"
            android:orientation="horizontal">
            <ImageView
                android:id="@+id/ImageView08"
                android:layout_gravity="center"
                android:background="@drawable/line"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"></ImageView>
        </LinearLayout>
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="15dip"
            android:id="@+id/linear5"
            android:orientation="horizontal">
            <TextView android:text="Market data delayed at least 15 minutes "
                android:id="@+id/TextView16"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/gray2"></TextView>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/linear8"
        android:background="@color/white"
        android:layout_alignParentBottom="true">
        <ImageView android:id="@+id/ImageView15"
            android:src="@drawable/quest_i"
                android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></ImageView>
    </LinearLayout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="200dip"
        android:background="@color/white"
        android:id="@+id/mainlinear3"
        android:layout_above="@+id/linear8"
        android:layout_below="@+id/mainlinear2"
        android:layout_weight="1">
    </LinearLayout>
</RelativeLayout>
<!--</ScrollView>-->
</code>```

答:
why you are making it a single view....
Attach two imageView header and footer to the scrollview .</p>

<p>|ImageView|  |/ImageView|
|ScrollView| |/ScrollView|
|ImageView| |/ImageView| </p>

Title: layout problem in android

Body:
I am creating fixed header and fixed footer for RelativeLayout. In the center part I am adding array of WebView when it come ScrollView it hide header and footer.

How can I avoid that?

This is my layout file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainrelativelayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:id="@+id/mainlinear2"
        android:layout_alignParentTop="true"
        android:orientation="vertical">
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="15dip"
            android:orientation="horizontal"
            android:id="@+id/linear5">
            <TextView android:text=" "
                android:id="@+id/txtwebservice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/gray2"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="6dip"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView08"
                android:layout_gravity="center"
                android:background="@drawable/line"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"></ImageView>
        </LinearLayout>
        <LinearLayout mlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView android:paddingRight="75dip"
                android:paddingLeft="20dip"
                android:text="Index"
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textStyle="bold"></TextView>
            <TextView android:paddingRight="60dip"
                android:text="Last"
                android:id="@+id/TextView02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textStyle="bold"></TextView>
            <TextView android:text="Change"
                android:id="@+id/TextView03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textStyle="bold"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="6dip"
            android:orientation="horizontal">
            <ImageView
                android:id="@+id/ImageView08"
                android:layout_gravity="center"
                android:background="@drawable/line"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"></ImageView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear2"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView05"
                android:paddingTop="5dip"
                android:layout_gravity="center"
                android:background="@drawable/down"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView
                android:paddingRight="30dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView
                android:paddingRight="55dip"
                android:text=""
                android:id="@+id/txtlast0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/red1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear3"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView02"
                android:layout_gravity="center"
                android:background="@drawable/up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView
                android:paddingRight="46dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:paddingRight="64dip"
                android:text=""
                android:id="@+id/txtlast1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/green1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear4"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView03"
                android:layout_gravity="center"
                android:background="@drawable/up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView android:paddingRight="69dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:paddingRight="67dip"
                android:text=""
                android:id="@+id/txtlast2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/green1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linear4"
            android:orientation="horizontal">
            <ImageView android:id="@+id/ImageView04"
                android:layout_gravity="center"
                android:background="@drawable/up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageView>
            <TextView android:paddingRight="61dip"
                android:paddingLeft="10dip"
                android:text=""
                android:id="@+id/txtindex3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:paddingRight="65dip"
                android:text=""
                android:id="@+id/txtlast3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="12dip"></TextView>
            <TextView android:text=""
                android:id="@+id/txtchange3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/green1"></TextView>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:id="@+id/linear1"
            android:layout_height="4dip"
            android:orientation="horizontal">
            <ImageView
                android:id="@+id/ImageView08"
                android:layout_gravity="center"
                android:background="@drawable/line"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"></ImageView>
        </LinearLayout>
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="15dip"
            android:id="@+id/linear5"
            android:orientation="horizontal">
            <TextView android:text="Market data delayed at least 15 minutes "
                android:id="@+id/TextView16"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dip"
                android:textColor="@color/gray2"></TextView>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/linear8"
        android:background="@color/white"
        android:layout_alignParentBottom="true">
        <ImageView android:id="@+id/ImageView15"
            android:src="@drawable/quest_i"
                android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></ImageView>
    </LinearLayout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="200dip"
        android:background="@color/white"
        android:id="@+id/mainlinear3"
        android:layout_above="@+id/linear8"
        android:layout_below="@+id/mainlinear2"
        android:layout_weight="1">
    </LinearLayout>
</RelativeLayout>

Body:
why you are making it a single view....
Attach two imageView header and footer to the scrollview .

|ImageView|  |/ImageView|
|ScrollView| |/ScrollView|
|ImageView| |/ImageView|