RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-292687

Дмитрий Позолота's questions

Martin Hope
Дмитрий Позолота
Asked: 2022-06-24 19:31:34 +0000 UTC

如何从kotlin中的字符串中替换部分元素?

  • 1

有一个格式为+7 (960) 454 343 88的字符串。如何用符号#替换某些元素,使总数为+7 (960) ## ##3 88?

replaceRange方法用单个字符替换所有元素,包括空格

kotlin
  • 2 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-09-14 00:10:49 +0000 UTC

ImageView 的动态占位符

  • 0

有一个ImageView元素,其高度和宽度具有wrap_content属性。

... 
           <ImageView
                android:id="@+id/previewImageView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/size_ssmall"
                android:adjustViewBounds="true"
                android:visibility="gone"
                app:layout_constraintBottom_toTopOf="@id/upsTextView"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/titleTextView"
                app:layout_constraintVertical_chainStyle="packed" />
...

通过毕加索,我通过 url 加载图像。如果原始尺寸超过 600 像素,我会裁剪图像的高度。

Picasso.with(context)
   .load(url)
   .resize(0, 600)
   .onlyScaleDown()
   .into(previewImageView)

因此,加载的图像可以是任意大小的高度和宽度,但高度不超过 600 像素。如果图像的原始大小未知,如何用占位符替换图像?

问题是多个图像位于recyclerView中,如果正在加载的图像的宽度或高度小于占位符的宽度或高度,则ViewHolder本身的大小会发生变化,如果用户位于列表中间,则从图像上方加载后,它会向上或向下抛出几个像素,这不是很顺眼。

android
  • 1 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-08-02 01:19:50 +0000 UTC

如何用颜色填充android中行之间的区域?

  • 1

有一段代码可以创建两条从左侧延伸到顶部的曲线。考虑到线条可以移动的事实,如何用正确的颜色填充它们之间形成的区域?

在此处输入图像描述

public class DrawView extends View {

Paint paint;
Path path1 = new Path();
Path path2 = new Path();

public DrawView(Context context) {
    super(context);
    init();
}

public DrawView(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
}

public DrawView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    init();
}

private void init() {
    paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
}

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    path1.reset();
    path2.reset();

    paint.setColor(Color.RED);
    paint.setStrokeWidth(3);

    path1.moveTo(0, 750);
    path2.moveTo(0, 900);

    path1.cubicTo(185, 250, 599, 177, 585, 0);
    path2.cubicTo(350, 250, 750, 177, 900, 0);

    canvas.drawPath(path1, paint);
    canvas.drawPath(path2, paint);

 }
}
android
  • 1 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-04-13 21:51:44 +0000 UTC

如何在 rxjava 中连接两个 Single?

  • 1

该方法在执行之后itemDao.findItemsByDetails()返回Single<List<Int>,我们开始执行getItemsByIds()已经返回的方法Flowable<MutableList<Item>>。同时,我需要为列表的每个元素添加来自其他表的某些数据。例如,第一个getAllDetailsItems()返回Single.

如何结合两个结果Single,例如getAllDetailsItems()和getAllDescriptions()

override fun findItemsByDetails(listDetails: List<String>, count: Int): Flowable<MutableList<Item>> {
        return itemDao.findItemsByDetails(listDetails, count).flatMapPublisher { list ->
            itemDao.getItemsByIds(list).flatMapIterable { items -> items }.flatMapSingle {
                itemDao.getAllDetailsItems(it.idItem).map { list ->
                    mapper.mapDetailItem(it, list)
                }.toFlowable().toList()
            }
        }
}

我知道你可以使用 zip / zipWith,但我想不起来。

android
  • 1 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-04-11 22:30:39 +0000 UTC

如何在 SQLITE 中实现按条件搜索元素?

  • 1

共有三个表-Item和。在它们之间,它们创建了多对多的关系。如何实现对特定.DetailDetailsItemItemDetail

例如,有一把锤子。它由几个部分组成,例如:铁、木、铜。我需要详细找到这把锤子。例如,我驱动诸如wood和Copper之类的参数,这肯定会找到所需的元素,但如果我添加一个额外的参数(例如硅胶),则该元素将被丢弃。

此外,这些参数可能包含包含铁、木和铜的其他元素,但如果其中一个参数不匹配,则该元素不应显示在最终选择中。

SELECT item.idItem, detail.idDetail, detail.title FROM item 
JOIN details_item ON item.idItem = details_item.idItem 
JOIN detail ON detail.idDetail = details_item .idDetail 
WHERE detail.title in ("Железо","Дерево","Медь")

此查询查找具有这些部件的项目,但也显示只有 3 个材料匹配项中的 1 个的其他项目。

事先也不知道搜索的参数有多少,因为一个in (...)数组将被传递给

sqlite
  • 1 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-03-24 22:24:40 +0000 UTC

方法未在 RxJava2 中终止

  • 0

itemDao.getAllItems()返回Flowable<MutableList<ItemEntity>>

itemDao.getAllDetailsItem()返回Flowable<MutableList<DetailEntity>>

我首先需要获取Items列表,然后通过对数据库的以下查询,获取这些元素的Detail列表。由于我同时使用两个Item和ItemEntity 对象,因此我使用自己的Mapper类,该方法mapDetailItem返回 pojo Item类。

此方法有效,但进程不终止且方法loadLocalItem()不返回Flowable<MutableList<Item>>

  override fun loadLocalItem(): Flowable<MutableList<Item>> {
        return itemDao.getAllItems()
                .flatMap {
                    Flowable.fromIterable(it).flatMap { item ->
                        itemDao.getAllDetailsItem(item.idItem)
                                .map { details ->
                                    mapper.mapDetailItem(item, details)
                                }
                    }.toList().toFlowable()
                }
  }
kotlin
  • 1 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-03-21 21:16:49 +0000 UTC

如何使用 rxjava 从数据库返回修改后的列表?

  • 0

有一种方法可以将数据返回为Flowable<MutableList<Item>>. 该方法从数据库itemDao.getAllItems()中返回表单中的列表。Flowable<MutableList<ItemEntity>>要将对象从ItemEntity转换为Item ,我使用Mapper类使用方法mapDetailItem,我从另一个表中抛出一个零件列表,然后将其添加到Item对象中,然后返回对象本身,它已经有一个填充的列表字段。

如何对每个元素执行此操作并最终返回一个列表MutableList<Item>而不是MutableList<ItemEntity>

override fun loadLocalItems(): Flowable<MutableList<Item>> {
        return itemDao.getAllItems()
                .map { list ->
                    Flowable.fromIterable(list).map {
                        mapper.mapDetailItem(it, itemDao.getAllDetailItemsById(it.idItem))
                    }
                }
 }

使用一个元素,我这样做:

return itemDao.getItemById(id).map { mapper.mapDetailItem(it, itemDao.getAllDetailItemsById(it.idItem)) }
kotlin
  • 2 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-09-27 21:08:58 +0000 UTC

如何从方法中返回特定对象?

  • 1

在其中一个类中,调用了另一个类RequestInterface的方法

val requestInterface = RequestInterface.getRetrofitBuild(ExampleApi::class.java)

返回所需对象的getRetrofitBuild方法在哪里。

fun getRetrofitBuild(exampleApi : ExampleApi): ExampleApi {
            return Retrofit.Builder()
                    .baseUrl(baseDomain)
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .addConverterFactory(GsonConverterFactory.create())
                    .build().create(exampleApi::class)
}

我怎样才能做到这一点,以便在这种方法中不仅可以覆盖ExampleApi,还可以覆盖其他对象,例如SimpleApi?

interface ExampleApi { 
    @GET("getItems?") 
    fun getAllItems(@Query("type") type: String): Observable<List<Items>> }

interface SimpleApi { 
    @GET("getItems?") 
    fun getAllItems(@Query("lang") language: String): Observable<List<Items>> 
}
android
  • 1 个回答
  • 10 Views
Martin Hope
Дмитрий Позолота
Asked: 2020-07-27 17:12:30 +0000 UTC

返回后如何显示嵌套片段?

  • 1

有一个主活动MainActivity,framelayout所在的位置

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/mainContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>

一个带有导航的片段被放置在那里,其中嵌套的片段由选项卡切换。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/navigationContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/tabLayout" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        style="@style/AppTabLayout"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_alignParentBottom="true"
        android:background="#FFFFFF"
        android:elevation="@dimen/size_medium"
        tools:targetApi="lollipop">

        <android.support.design.widget.TabItem
            android:layout_width="@dimen/size_large"
            android:layout_height="@dimen/size_large"
            android:icon="@drawable/ic_nav_main" />

        <android.support.design.widget.TabItem
            android:layout_width="@dimen/size_large"
            android:layout_height="@dimen/size_large"
            android:icon="@drawable/ic_nav_popular" />

        <android.support.design.widget.TabItem
            android:layout_width="@dimen/size_large"
            android:layout_height="@dimen/size_large"
            android:icon="@drawable/ic_nav_favorites" />

    </android.support.design.widget.TabLayout>

</RelativeLayout>

我改变这样的片段:

val transaction = fragmentManager?.beginTransaction()
transaction?.replace(R.id.navigationContainer, fragment, screenKey)
?.addToBackStack(screenKey)?.commit()

当我需要显示没有底部导航的片段时,我不是通过navigationContainer而是通过mainContainer 更改片段。

val transaction = fragmentManager?.beginTransaction()
transaction?.replace(R.id.mainContainer fragment, screenKey)
?.addToBackStack(screenKey)?.commit()

而当我们按下后退按钮时,我们会显示一个导航片段,但是 navigationContainer 容器中的嵌套片段变成了空的。

android
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5