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

(我用素描来创建)
有技巧或窍门吗?
以防万一,如果您知道如何在上增加最高利润bottomsheetdialog,我也想知道这一点;)
我遇到的问题是我的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) 现在,我们的服务器将FCM“通知”类型的消息发送到Android设备。是否可以在通知中添加“ Inline回复”(如此处所述)操作,而无需借助“数据”类型的消息并在应用程序中处理通知?
android push-notification android-notifications firebase firebase-cloud-messaging
当我收到来自 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}}
任何机构都可以帮助从通知负载中获取数据吗?
我一直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) 我可以在服务内部使用此代码来延迟调用方法,还是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) 我正在使用 FlexboxLayout
下面加依存性build.gradle的FlexboxLayout
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)
我收到以下错误错误ScreenShot
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) 我想使用 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 帖子但无法找到任何解决方案
如果需要更多信息,请告诉我。提前致谢。您的努力将受到赞赏。
我想让我的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) 我在项目中添加 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 ×8
bottom-sheet ×2
dart ×2
flutter ×2
caching ×1
dagger-hilt ×1
firebase ×1
fragment ×1
kotlin ×1
phone-number ×1
post ×1
shapes ×1