小编Pab*_* R.的帖子

使用 Gorm 更新为 0 值

我正在尝试使用 gorm 库更新一些值,但值为 0 的字节和整数未更新

var treatment model.TreatmentDB

err = json.Unmarshal(b, &treatment)
if err != nil {
    http.Error(w, err.Error(), 500)
    return
}

fmt.Println(&treatment)

db := db.DB.Table("treatment").Where("id = ?", nID).Updates(&treatment)
Run Code Online (Sandbox Code Playgroud)

这个打印值是{0 3 1 0 0 0 2018-01-01 4001-01-01},那些0是未更新的字节值(数据库中的tinyint(1),如果我更改为int也不起作用) ,其余值工作正常

如果我在不使用 Gorm 的情况下更新它们,它可以完美地使用 0 值

var query  = fmt.Sprintf("UPDATE `pharmacy_sh`.`treatment` SET `id_med` = '%d', `morning` = '%d', `afternoon` = '%d', `evening` = '%d', `start_treatment` = '%s', `end_treatment` = '%s' WHERE (`id` = '%s')", treatment.IDMed, treatment.Morning,  treatment.Afternoon, treatment.Evening, treatment.StartTreatment, treatment.EndTreatment, nID)

update, err …
Run Code Online (Sandbox Code Playgroud)

mysql go go-gorm

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

固定状态栏和隐藏的导航栏

是否可以隐藏导航栏而不隐藏状态栏?

我在我的样式的 xml 中试过这个

  <item name="android:windowFullscreen">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
Run Code Online (Sandbox Code Playgroud)

我在活动中像这样隐藏了导航栏

  val decorView = window.decorView
        val uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        decorView.systemUiVisibility = uiOptions
Run Code Online (Sandbox Code Playgroud)

谢谢!!

编辑:

   fun hideNavigationStatusBar(activity: Activity) {
        activity.window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
        val decorView = activity.window.decorView
        val uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        decorView.systemUiVisibility = uiOptions
    }

    fun translucidNavigationBar(activity: Activity) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            val w = activity.window
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                    WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
        }
    }
Run Code Online (Sandbox Code Playgroud)

我可以使用第一种方法隐藏状态和导航栏,并使用第二种方法通过半透明导航保持状态,但我仍然无法保持状态并完全隐藏导航栏。

android statusbar android-layout

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

Android数据绑定src ImageView在xml中

我正在显示包含项目的列表

<include
        layout="@layout/item_tags"
         android:title='@{"text"}'
         android:image='@{"@drawable/ic_write_item.xml"}'/>
Run Code Online (Sandbox Code Playgroud)

这个布局包含

<layout xmlns:android="http://schemas.android.com/apk/res/android">
    <data>
        <variable
            name="title"
            type="java.lang.String" />

        <variable
            name="image"
            type="java.lang.String" />
    </data>
Run Code Online (Sandbox Code Playgroud)

...

  <ImageView...
                    android:src="@{image}"/>

                <TextView...
                    android:text="@{title}" />
Run Code Online (Sandbox Code Playgroud)

还创建了myDatabindingAdapter

object DataBindingAdapters {

    @BindingAdapter("android:src")
    @JvmStatic
    fun setImageUri(view: ImageView, imageUri: Uri) {
        view.setImageURI(imageUri)
    }

    @BindingAdapter("android:src")
    @JvmStatic
    fun setImageDrawable(view: ImageView, drawable: Drawable) {
        view.setImageDrawable(drawable)
    }

    @BindingAdapter("android:src")
    @JvmStatic
    fun setImageResource(imageView: ImageView, resource: Int) {
        imageView.setImageResource(resource)
    }
}
Run Code Online (Sandbox Code Playgroud)

并以这种方式在片段中初始化

 val binding: FragmentTagsBinding =  DataBindingUtil.inflate(inflater,R.layout.fragment_tags, container,false)

        return binding.root
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到以下错误。

E/BitmapFactory:无法解码流:java.io.FileNotFoundException:@drawable/ic_write_item.xml(没有这样的文件或目录)W/ImageView:resolveUri 在错误的位图 uri 上失败:@drawable/ic_write_item.xml

是不是适配器有问题?我应该发送资源id而不是文件名吗?

谢谢你的帮助。

android android-layout android-databinding

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

重定向错误 404 Angular 5

我试图在 url 错误时处理 404 错误,http://localhost:8100/#/login。这是我的登录 url,如果我写类似 http:.../loginasdasd 的内容,我想自动打开我自己的 NotFoundPage。

const appRoutes3: Routes = [
  {
    path: '',
    children: [
      {
         path: 'login',
         component: LoginPage
      },
      { path: 'login**', redirectTo: '/notfound' }
   ]
 },
 { path: 'notfound', component: NotFoundPage }
];


RouterModule.forRoot(
  appRoutes3,
  { enableTracing: true } // <-- debugging purposes only
)
,
IonicModule.forRoot(MyApp, {}, {
  links: [
    { component: HomePage, name: "Home", segment: "" },
    { component: LoginPage, name: "Login", segment: "login", defaultHistory: [HomePage] },
    { component: …
Run Code Online (Sandbox Code Playgroud)

http-status-code-404 angular

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