小编Gok*_*oku的帖子

具有底部粘滞按钮的BottomSheetDialogFragment

我在显示按钮时遇到一些麻烦BottomSheetDialogFragment。无论它是展开还是折叠,我都希望它粘在我底部的底部。

见下图:

我想做的事

(我用素描来创建)

有技巧或窍门吗?

以防万一,如果您知道如何在上增加最高利润bottomsheetdialog,我也想知道这一点;)

android bottom-sheet

7
推荐指数
2
解决办法
889
查看次数

使用StringRequest的Volley在第一次之后不调用getParams来发送POST请求参数

我遇到的问题是我的POST请求参数在第一次之后没有进入服务器.我知道Volley使用缓存机制进行响应,但在我的情况下,我的请求参数值可以在运行时更改,因为我正在使用分页Recyclerview.

所以我的问题是如何每次都发送Post请求参数而不会松散缓存机制volley.

我已经尝试使用下面的那些并完成我的事情(getParams()每次调用)..但它失去了缓存响应,我不希望这样.

requestQueue.getCache().clear();

stringRequest.setShouldCache(false);

也有搜索谷歌和以下链接,但无法找到任何适当的解决方案.以下是SO链接

以下是我的代码:

        StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {

                Log.e("RES", response);


                GsonBuilder gsonBuilder = new GsonBuilder();
                gsonBuilder.setDateFormat("M/d/yy hh:mm a"); //Format of our JSON dates
                Gson gson = gsonBuilder.create();

                NewsFeedPOJO resultObj = (NewsFeedPOJO) gson.fromJson(response, (Class) NewsFeedPOJO.class);

                inCurrPage = Integer.parseInt(resultObj.getPagination().getCurrent_page());
                inTotalPage = Integer.parseInt(resultObj.getPagination().getTotal_pages());
                inCurrPage++;

                arrayList.addAll(resultObj.getNewsFeedList());
                if (isFtym) {
                    isFtym = false;
                    layoutManager = new …
Run Code Online (Sandbox Code Playgroud)

post android caching android-volley

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

如何添加对“通知” firebase消息的内联回复?

现在,我们的服务器将FCM“通知”类型的消息发送到Android设备。是否可以通知中添加“ Inline回复”(如此处所述)操作,而无需借助“数据”类型的消息并在应用程序中处理通知?

android push-notification android-notifications firebase firebase-cloud-messaging

6
推荐指数
0
解决办法
326
查看次数

Flutter:如何从 firebase 通知负载获取 Json 数据

当我收到来自 firebase 的通知时,我需要显示自定义对话框。但我不知道如何从通知负载中获取我的数据

我试过下面的代码,但它是机器人为我工作

  Future<void> _handleNotification(
    Map<dynamic, dynamic> message, bool dialog) async {
    final dynamic data = message['data'] ?? message;
    final dynamic notification = message['notification']['body'] ?? message;

    final String itemId = data['body'];

    debugPrint("DATA ->> $data");
    debugPrint("notification ->> $notification");
    message.forEach((k, v) => debugPrint("${k} - ${v}"));
  }
Run Code Online (Sandbox Code Playgroud)

这是我在控制台中的有效载荷

flutter: 通知消息 {gcm.message_id: 1578573493122232, id: 30, google.cae: 1, type: test, aps: {alert: {title: notication title, body: Message of Push notification}, sound: 1}}

任何机构都可以帮助从通知负载中获取数据吗?

dart flutter firebase-cloud-messaging

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

如何使BottomSheetDialogFragment覆盖全屏?

我一直BottomSheetDialogFragment在显示一些数据,但是当我开始显示时,fragment它会出现在屏幕的50%左右。所以,我的问题是如何在显示时使其全屏显示。

BottomSheetDialogFragment 码:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.bot_frag, container, false);
    TextView tv = v.findViewById(R.id.textVi);
    back=v.findViewById(R.id.back_of_bot);
    back.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();
                }
            }
    );
    return v;
}
Run Code Online (Sandbox Code Playgroud)

android fragment bottom-sheet

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

在服务内部使用处理程序

我可以在服务内部使用此代码来延迟调用方法,还是Handler()只能在UI线程内部使用?

在a内部延迟调用方法的最佳方法是service什么?

final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
  @Override
  public void run() {
    //Do something after 10000ms
    socket.emit("CancelTravel");
  }
}, 10000);
Run Code Online (Sandbox Code Playgroud)

android

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

java.lang.NoClassDefFoundError:使用FlexboxLayout时的androidx/core/view/ViewCompat

我正在使用 FlexboxLayout

下面加依存性build.gradleFlexboxLayout

dependencies {
    implementation 'com.google.android:flexbox:1.1.0'
}
Run Code Online (Sandbox Code Playgroud)

myLayout

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.flexbox.FlexboxLayout
    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="match_parent">



</com.google.android.flexbox.FlexboxLayout>
Run Code Online (Sandbox Code Playgroud)

我收到以下错误错误Scre​​enShot

java.lang.NoClassDefFoundError: androidx/core/view/ViewCompat
    at com.google.android.flexbox.FlexboxLayout.onLayout_Original(FlexboxLayout.java:565)
    at com.google.android.flexbox.FlexboxLayout.onLayout(FlexboxLayout.java)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at android.support.v7.widget.ActionBarOverlayLayout.onLayout_Original(ActionBarOverlayLayout.java:444)
    at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:348)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:386)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:450)
    at …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-flexboxlayout

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

如何在android中使用xml可绘制创建半圆填充形状?

我想使用 xml Drawble 创建一个半填充的圆形形状?

像这样在此输入图像描述

这是我迄今为止尝试过的努力

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#FCD83500"/>
    <size
        android:width="10dp"
        android:height="5dp"/>
    <corners
        android:bottomLeftRadius="50dp"
        android:bottomRightRadius="50dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

使用上面的代码我可以创建半圆,但我不知道如何使半圆透明

我也访问过一些 SO 帖子但无法找到任何解决方案

如果需要更多信息,请告诉我。提前致谢。您的努力将受到赞赏。

android shapes android-drawable

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

Flutter – 如何格式化电话号码文本字段

我想让我的TextFormField格式以正确的电话号码格式输入号码。

我试过在下面使用 TextInputFormatter

class NumberTextInputFormatter extends TextInputFormatter {
  @override
  TextEditingValue formatEditUpdate(
      TextEditingValue oldValue, TextEditingValue newValue) {
    final int newTextLength = newValue.text.length;
    int selectionIndex = newValue.selection.end;
    int usedSubstringIndex = 0;
    final StringBuffer newText = new StringBuffer();
    if (newTextLength >= 1) {
      newText.write('+');
      if (newValue.selection.end >= 1) selectionIndex++;
    }
    if (newTextLength >= 3) {
      newText.write(newValue.text.substring(0, usedSubstringIndex = 1) + ' ');
      if (newValue.selection.end >= 2) selectionIndex += 1;
    }
    if (newTextLength >= 3) {
      newText.write( ' ');
      if (newValue.selection.end >= …
Run Code Online (Sandbox Code Playgroud)

phone-number dart flutter flutter-layout

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

Hilt java.lang.IllegalStateException:不支持的元数据版本。检查您的 Kotlin 版本是否 &gt;= 1.0

我在项目中添加 hilt 依赖项时遇到问题

插件

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'realm-android'
    id 'androidx.navigation.safeargs.kotlin'
    id 'kotlin-parcelize'
}
Run Code Online (Sandbox Code Playgroud)

依赖关系

//Dependency injection with Hilt 
implementation("com.google.dagger:hilt-android:2.38.1")
kapt("com.google.dagger:hilt-android-compiler:2.38.1")
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
Run Code Online (Sandbox Code Playgroud)

build.gradle 项目级别

buildscript {

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'
        classpath "io.realm:realm-gradle-plugin:10.11.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0"
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.42"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' …
Run Code Online (Sandbox Code Playgroud)

android dependency-injection kotlin dagger-hilt

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