小编dav*_*don的帖子

如何检查字符串是否包含Bash中的子字符串

我在Bash中有一个字符串:

string="My string"
Run Code Online (Sandbox Code Playgroud)

如何测试它是否包含另一个字符串?

if [ $string ?? 'foo' ]; then
  echo "It's there!"
fi
Run Code Online (Sandbox Code Playgroud)

??我的未知运营商在哪里?我是否使用echo grep

if echo "$string" | grep 'foo'; then
  echo "It's there!"
fi
Run Code Online (Sandbox Code Playgroud)

这看起来有点笨拙.

string bash substring

2332
推荐指数
23
解决办法
189万
查看次数

如何从layout.xml中删除默认的cardview边框

我无法删除CardView的默认边框.以前有人遇到过这个问题吗?

两条边界线重叠

两条边界线重叠

CardviewDesign.xml

<android.support.v7.widget.CardView
    xmlns:android="https://schemas.android.com/apk/res/android"
    xmlns:android2="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="https://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/card_view"
    android:layout_width="match_parent"

    android2:layout_marginTop="5dp"
    android2:layout_marginLeft="5dp"
    android2:layout_marginRight="5dp"
    android2:layout_gravity="center|top"

    card_view:cardCornerRadius="20dp"
    android2:layout_width="match_parent"
    android2:layout_height="wrap_content">

<FrameLayout
    android2:layout_width="match_parent"
    android2:layout_height="400dp"

    android2:background="@drawable/cardviewstring">



    <LinearLayout
        android2:orientation="vertical"
        android2:layout_width="380dp"
        android2:layout_height="match_parent"


        android2:weightSum="1"
        android2:layout_marginRight="20dp">

        <LinearLayout
            android2:orientation="vertical"
            android2:layout_width="match_parent"
            android2:layout_weight="1"
            android2:layout_height="250dp">

            <ImageView
                android2:layout_width="match_parent"
                android2:layout_height="match_parent"
                app:srcCompat="@mipmap/ic_launcher"
                android2:id="@+id/imageView4" />

        </LinearLayout>

        <LinearLayout
            android2:orientation="vertical"
            android2:layout_width="match_parent"
            android2:layout_height="wrap_content"
            android2:paddingTop="25dp">

            <ScrollView
                android2:layout_width="match_parent"
                android2:layout_height="84dp"
                android2:background="@drawable/screen_background_dark_transparent"
                android2:layout_marginLeft="3dp">

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

                    <TextView
                        android2:text="TextView"
                        android2:layout_width="match_parent"
                        android2:layout_height="wrap_content"
                        android2:id="@+id/textView4" />

                    <TextView
                        android2:text="TextView"
                        android2:layout_width="match_parent"
                        android2:layout_height="35dp"
                        android2:id="@+id/textView3" />
                </LinearLayout>
            </ScrollView>

        </LinearLayout>

        <LinearLayout
            android2:orientation="vertical"
            android2:layout_marginTop="10dp"
            android2:layout_width="match_parent"
            android2:layout_height="42dp"
            android:layout_alignParentBottom="true">

            <LinearLayout
                android2:orientation="horizontal"
                android2:layout_width="match_parent"
                android2:layout_height="match_parent"> …
Run Code Online (Sandbox Code Playgroud)

xml android uiview android-layout android-xml

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

为什么Hibernate Serializable中的生命周期监听器?

您实现的Hibernate接口提供事件侦听器,例如:org.hibernate.event.PostInsertEventListener;all extend Serializable.

但是,它似乎无法解释为什么您的侦听器需要可序列化.我们已经将DAO与数据库连接注入了一段时间,但它还没有失败,但我担心可能会出现Hibernate通过序列化链接传递监听器的情况,因此会丢失数据库连接.

所以问题是:为什么hibernate事件监听器必须是可序列化的?

java hibernate

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