小编Mar*_*cus的帖子

我怎样才能在NestedScrollView中有一个ListView

我创建了一个带有页面的应用程序,需要从Web服务动态加载内容.我希望listview能够与NestedScrollView中的线性布局一起滚动.但是当内容加载到列表视图时,它不会延伸到其完整高度.

这是我的代码.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.myquestionth.myquestionth10.Profile2Activity"
    tools:showIn="@layout/activity_profile2">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#BBBBBB" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Media heading"
                android:id="@+id/textView2" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis."
                android:id="@+id/textView8" />

        </LinearLayout>

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#70bcf5" />

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

我有一些关于scrollview的搜索无法嵌套.根据我在Google Play评论页面设计的布局,这是我想要的一个例子.他们使用的方法是什么?建议我,如果我做错了什么.非常感谢.

在此输入图像描述

这就是我想要的.

在此输入图像描述

java layout android listview android-nestedscrollview

6
推荐指数
2
解决办法
1万
查看次数

如何在工具栏下方放置一个TabLayout位置?

当我尝试在工具栏下面添加TabLayout时得到了一些提示。我尝试通过添加来尝试解决此问题中建议的选项卡<android.support.design.widget.TabLayout />,但该选项卡位于工具栏的顶部。而且,当我做这个博客之类的事情时,它仍然无法正常工作。

这是我的代码。我从创建它,scrolling activity然后通过添加进行更改tablayout

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.myquestionth.myquestionth10.activity.Profile4Activity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabGravity="fill"
                app:tabMode="fixed" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_profile4" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="bottom|end" />

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

我只希望Tablayout放置如下:

而这在滚动工具栏时:

请帮助和建议。

android android-layout android-fragments android-studio android-tablayout

5
推荐指数
1
解决办法
3115
查看次数

如何用XML编写具有多个名称空间的XSD文件?

当我在mec.xsd中定义XML模式时,它不适用于该元素。我该如何解决?谢谢。

<l:primary>XML</l:primary>
Run Code Online (Sandbox Code Playgroud)

mec.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.example.com mc.xsd"
         xmlns:l="http://www.example2.com"
         xmlns="http://www.example.com"> 
    <person>
        <name>Marcus</name>
        <language>
            <l:primary>XML</l:primary>
        </language>
    </person>
</people>
Run Code Online (Sandbox Code Playgroud)

mc.xsd

<xs:schema version="1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.example.com"
           xmlns="http://www.example.com"
           elementFormDefault="qualified">
    <xs:element name="people">
        <xs:complexType mixed="true">
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="person">
                    <xs:complexType mixed="true">
                        <xs:sequence>
                            <xs:element name="name" type="xs:string"/>
                            <xs:element name="language">
                                <xs:complexType mixed="true">
                                    <xs:element name="primary" type="xs:string"/>            
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

xml xsd

3
推荐指数
1
解决办法
3831
查看次数

如何使用 mysql 数据库创建阻塞系统?

我创建了一个小型社交网站,其中包含三个简单的表格,如下所示。

Table User
id (pk)  | user_name
1       | a
2       | b
3       | c

Table Post
id (pk)  | user_id (fk)
1       | 1
2       | 3
3       | 2
4       | 2

Table Block
id (pk) | block_by (fk)  | blocked_to (fk)
1       | 1              | 2
Run Code Online (Sandbox Code Playgroud)

用户可以阻止他们想要的任何人,如果阻止发生,两个用户将不再在他们的新提要上看到彼此的帖子。

从我的表来看,这意味着user1并且user2不会看到彼此的帖子,但“user3”通常会看到每个人的帖子,因为他不属于表块。

    select * from Post p 
where p.user_id not in 
(select b.blocked_to from Block b  
where b.block_by = '$_SESSION[userid]')
Run Code Online (Sandbox Code Playgroud)

从 SQL 查询 user1 看不到 user2 …

php mysql sql

2
推荐指数
1
解决办法
2307
查看次数

如何使用JavaScript删除html标签并保留换行符?

当我从剪贴板粘贴某些内容时,我想仅从contenteditablediv保留项newlinebr标签中删除富文本格式。

我正在尝试,但是不起作用 http://jsfiddle.net/marco83/zkf5jkqu/

<div id="editableDiv" contentEditable="true" style="min-height: 200px; border: solid 1px #0099FF;"></div>

<input type="button" value="remove" onclick="strip();">

<script>
function strip() {
    var mydiv = document.getElementById("editableDiv");
    var str  = mydiv.innerHTML;
    str = str.replace(/<br>/gi, "\n");
    str = str.replace(/<(?:.|\s)*?>/g, "");
    mydiv.innerHTML = str;
}
</script>
Run Code Online (Sandbox Code Playgroud)

我从此页面复制文本http://www.jacklmoore.com/autosize/
我知道它没有任何<br>标记文本。但是我怎么能像Twitter这样呢?谢谢。

在此处输入图片说明

html javascript jquery replace preg-replace

2
推荐指数
1
解决办法
1638
查看次数

Android:如何检测通知ID是否存在?

是否可以检测通知栏中是否存在附带唯一ID的通知?

mNotificationManager.notify(100, mBuilder.build());
Run Code Online (Sandbox Code Playgroud)

表单示例,我创建了ID为100的通知.下次当我再次使用该ID创建通知时,我不希望它更新.我用了setOnlyAlertOnce(true),声音消失了,但它仍然更新了通知并将其移至顶部.

android broadcastreceiver push-notification android-notifications intentservice

1
推荐指数
1
解决办法
2153
查看次数

如何避免在每个查询中使用$ conn?

我只是将我的代码从mysql改为mysqli,它似乎是最好的,如果:

如何避免$conn在每个查询或某些mysqli的函数中使用?

$conn = mysqli_connect("localhost", "test", "", "world"); 
$result = mysqli_query($conn, "select * from user where id = '1'");
$result = mysqli_query($conn, "select * from company where name = 'marcus'");
$result = mysqli_query($conn, "...");
mysqli_real_escape_string($conn, "my string");
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

mysqli_query("select * from user where id = '1'");
mysqli_real_escape_string("my string");
Run Code Online (Sandbox Code Playgroud)

使用$conn->query("...")不是我正在寻找的,因为它没有Dreamweaver的自动建议.

php mysql mysqli

0
推荐指数
1
解决办法
204
查看次数