小编Viv*_*art的帖子

没有htaccess的PHP中的URL重写

网站正在我们无法访问.htaccess文件的Web主机上运行.但是,我想为用户友好的URL进行URL重写.

例如原始URL

www.example.com/file?q=name
Run Code Online (Sandbox Code Playgroud)

预期的URL

www.example.com/file/name
Run Code Online (Sandbox Code Playgroud)

php web-hosting

21
推荐指数
2
解决办法
3万
查看次数

如何将手机号码分为国家代码,区号和本地号码?

如何将手机号码分为国家代码,区号和本地号码?拆分后例如+919567123456

国家代码= 91

区号= 9567

当地号码= 123456

java formatting localization

18
推荐指数
3
解决办法
5万
查看次数

RecyclerView切断最后一项

在此输入图像描述 我们可以看到这里最后一项是部分可见的.我怎样才能解决这个问题?layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinator_layout"
    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="wrap_content"
    android:fitsSystemWindows="true">

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

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

            <include
                layout="@layout/header"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

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

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/grey_background">

    <ImageView
        android:id="@+id/image"
        android:layout_width="@dimen/thumbnail_width"
        android:layout_height="@dimen/thumbnail_height"
        android:layout_gravity="center"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/image"
        android:orientation="vertical"
        android:padding="@dimen/participant_left_padding">

        <TextView
            android:id="@+id/participants_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="name"
            android:textColor="@android:color/white"/>

        <TextView
            android:id="@+id/total_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="view"
            android:textColor="@android:color/white"/>

        <TextView
            android:id="@+id/ranking"
            android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

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

jetpack compose viewModel() 使用刀柄给出错误“没有零参数构造函数”

在我的项目中,compose viewModel() 方法在我使用刀柄时给出错误“没有零参数构造函数”。

@Composable
    fun HomeScreen(homeViewModel: HomeViewModel = viewModel()) {
    ...
    }
    
    @HiltViewModel
    class HomeViewModel @Inject constructor(private val repository: Repository) :
        ViewModel() {
    ...
    }
@Module
@InstallIn(ViewModelComponent::class)
abstract class DataModule {
    @Binds
    abstract fun bindRepository(
        fakePuppyRepository: RepositoryImpl
    ): Repository
}
Run Code Online (Sandbox Code Playgroud)

这些是我的依赖项

implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
    implementation 'androidx.activity:activity-compose:1.3.0-alpha03'
    implementation "androidx.navigation:navigation-compose:1.0.0-alpha08"
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
    implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta01'
    implementation "com.google.dagger:hilt-android:$hilt_version"
    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
    kapt "com.google.dagger:hilt-compiler:$hilt_version"
    kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha03'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose dagger-hilt

10
推荐指数
2
解决办法
1595
查看次数

添加侦听器与set侦听器

添加侦听器和设置侦听器之间有什么区别.

例如

addTextChangedListener(textWatcher);
setOnClickListener(clickListener);
Run Code Online (Sandbox Code Playgroud)

回答:

在aioobe回答之后,我在我的项目中对此进行了测试.所以我们可以这样做.

editText.addTextChangedListener(textWatcher1);
editText.addTextChangedListener(textWatcher2);
Run Code Online (Sandbox Code Playgroud)

但我们不能这样做.(在这种情况下,它只设置最后一个监听器clickListener2)

button.setOnClickListener(clickListener1);
button.setOnClickListener(clickListener2);
Run Code Online (Sandbox Code Playgroud)

另一个疑问

我无法想到我需要两个textWatcher用于单个editText的任何用例.任何人都可以提供这样的用例.(我应该将这个问题作为单独的问题提出来吗?)

java android

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

当RecyclerView为空时,CollapsingToolbarLayout不会崩溃

我在我的项目中使用以下布局.它工作正常但是,即使RecyclerView为空或者RecyclerView的项目非常少,CollapsingToolbarLayout也会折叠.我想要的行为是,只有当RecyclerView的项目大于可见项目时,CollapsingToolbarLayout才会折叠.我怎样才能实现这种行为?

<?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinator_layout"
        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="wrap_content"
        android:fitsSystemWindows="true">

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

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

                <include
                    layout="@layout/header"
                    android:fitsSystemWindows="true"
                    app:layout_collapseMode="parallax"/>

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

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

android android-recyclerview androiddesignsupport android-collapsingtoolbarlayout

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

是否可以仅发布动态功能模块的更新?

我正在使用带有动态功能模块的 android 应用程序包。我创建了 2-3 个功能模块。现在我想要所有这些功能和基本应用程序的单独发布周期。

那么是否可以仅发布更新的功能模块,并且用户设备仅获取这些更新的模块的更新?

android android-app-bundle

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

如何以编程方式为CollapsingToolbarLayout设置expandedTitleMarginBottom

我们内部有一些隐藏的视图CollapsingToolbarLayout。因此,当我们使这些视图可见时,标题的对齐方式发生了变化。因此我们需要更改的值expandedTitleMarginBottom以调整对齐方式。

我们如何expandedTitleMarginBottomCollapsingToolbarLayout编程方式进行设置?

android android-collapsingtoolbarlayout

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

为字符串使用静态变量

以下内容取自 最佳实践:编写高效代码, 但我不明白为什么

private static String x = "example";
Run Code Online (Sandbox Code Playgroud)

比...快

private static final String x ="example";
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释一下.

为字符串使用静态变量

当您定义String类型的静态字段(也称为类字段)时,可以通过使用静态变量(而不是final)而不是常量(final)来提高应用程序速度.对于原始数据类型(例如int)则相反.

例如,您可以创建一个String对象,如下所示:

private static final String x = "example";
Run Code Online (Sandbox Code Playgroud)

对于此静态常量(由final关键字表示),每次使用常量时,都会创建一个临时String实例.编译器删除"x"并将其替换为字节码中的字符串"example",以便每次引用"x"时,BlackBerry®Java®VirtualMachine都会执行哈希表查找.

相反,对于静态变量(没有final关键字),String创建一次.BlackBerry JVM仅在初始化"x"时执行哈希表查找,因此访问速度更快.

private static String x = "example";
Run Code Online (Sandbox Code Playgroud)

您可以使用公共常量(即最终字段),但必须将变量标记为私有.

java blackberry

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

Teradata中减去和除外的差异

减去和除了teradata之间有什么区别?

sql teradata

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