小编Mol*_*lly的帖子

IllegalStateException:使用ViewPager在onSaveInstanceState之后无法执行此操作

我从我的应用程序中获取用户报告,提供以下异常:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1109)
at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:399)
at android.app.Activity.onBackPressed(Activity.java:2066)
at android.app.Activity.onKeyUp(Activity.java:2044)
at android.view.KeyEvent.dispatch(KeyEvent.java:2529)
at android.app.Activity.dispatchKeyEvent(Activity.java:2274)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1803)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1855)
at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1277)
at android.app.Activity.dispatchKeyEvent(Activity.java:2269)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1803)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.widget.TabHost.dispatchKeyEvent(TabHost.java:297)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1855)
at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1277)
at android.app.Activity.dispatchKeyEvent(Activity.java:2269)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1803)
at android.view.ViewRoot.deliverKeyEventPostIme(ViewRoot.java:2880)
at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2853)
at android.view.ViewRoot.handleMessage(ViewRoot.java:2028)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4028)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) …
Run Code Online (Sandbox Code Playgroud)

android illegalstateexception android-fragments android-viewpager fragmenttransaction

472
推荐指数
12
解决办法
30万
查看次数

如何在android中制作带圆角的自定义对话框

我想做的是:我正在尝试制作自定义对话框.圆角.

什么是happing:我能够进行自定义对话,但它没有圆角.我尝试添加一个选择器,但我还是不能


Java代码:

private void launchDismissDlg() {

        dialog = new Dialog(getActivity(), android.R.style.Theme_Dialog);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dlg_dismiss);
        dialog.setCanceledOnTouchOutside(true);

        Button btnReopenId = (Button) dialog.findViewById(R.id.btnReopenId);
        Button btnCancelId = (Button) dialog.findViewById(R.id.btnCancelId);

        btnReopenId.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {



            }
        });


        btnCancelId.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {



            }
        });
        dialog.setCanceledOnTouchOutside(false);
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
        dialog.show();

    }
Run Code Online (Sandbox Code Playgroud)

xml代码:

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

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center" >

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

android android-custom-view android-dialog

94
推荐指数
14
解决办法
10万
查看次数

如何在 next.js 应用程序中使用谷歌分析?

我在 next.js 中使用 styled-components,所以我的样式需要在服务器端呈现,因此我如何将谷歌分析添加到我的网站?

我检查了next.js 谷歌分析示例,但正如我所说,由于使用了样式组件,我的 _document 文件有所不同。

// _document.js

import React from 'react'
import Document from 'next/document'
import { ServerStyleSheet } from 'styled-components'

class MyDocument extends Document {
  static async getInitialProps(ctx) {
    const sheet = new ServerStyleSheet()
    const originalRenderPage = ctx.renderPage

    try {
      ctx.renderPage = () => originalRenderPage({
        enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
      })

      const initialProps = await Document.getInitialProps(ctx)
      return {
        ...initialProps,
        styles: (
          <>
            {initialProps.styles}
            {sheet.getStyleElement()}
          </>
        ),
      }
    } finally {
      sheet.seal() …
Run Code Online (Sandbox Code Playgroud)

javascript google-analytics reactjs styled-components next.js

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

java.lang.NullPointerException:缺少 ID 所需的视图:

安卓工作室 3.6

在 app/build.gradle 中:

android {
viewBinding.enabled = true
Run Code Online (Sandbox Code Playgroud)

这是我的 xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/bluetoothBottonMainContainer"
        android:layout_width="0dp"
        android:layout_height="104dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <View
            android:id="@+id/viewPointNotSelect"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:background="@drawable/circle_transparent"
            app:layout_constraintBottom_toBottomOf="@+id/separator"
            app:layout_constraintEnd_toStartOf="@+id/separator"
app:layout_constraintTop_toTopOf="parent" />
Run Code Online (Sandbox Code Playgroud)

和另一个 xml unclude prev。xml:

 <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/bottonContainer"
        android:layout_width="0dp"
        android:layout_height="104dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <include
            android:id="@+id/qrBottonContainer"
            layout="@layout/qr_bottom_container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />
Run Code Online (Sandbox Code Playgroud)

这是我的活动:

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = QrBluetoothSwipeActivityBinding.inflate(layoutInflater)
        setContentView(binding.root)
}
Run Code Online (Sandbox Code Playgroud)

该应用程序正在构建和运行。好的。

现在我移动 id - android:id="@+id/bluetoothBottonMainContainer"

到这样的外部容器:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" …
Run Code Online (Sandbox Code Playgroud)

android nullpointerexception android-viewbinding

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

如何模拟锚链接点击

我正在尝试触发.jquery的链接点击.有人知道为什么以下不起作用.

<!DOCTYPE  HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html lang="en"> 
  <head> 
    <title>test</title>
  </head>
  <body> 
    <div>
       <a id="google_link" href="http://google.com" target="_blank">click to go to google</a>
    </div>
    <div id="google_link_proxy">click here to do the same as the link above</div>

    <script type="text/javascript">      
     $("#google_link_proxy").click(function(event){
         $("#google_link").click();
     });
    </script>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

anchor jquery

26
推荐指数
3
解决办法
7万
查看次数

如何在android中进行url编码?

我使用网格视图使用xml解析显示图像,我有一些例外

java.lang.IllegalArgumentException:索引80处路径中的非法字符:http: //www.theblacksheeponline.com/party_img/thumbspps/912big_361999096_Flicking Off Douchebag.jpg

如何解决这个问题呢?我想显示所有类型的网址,有人知道请为我提供示例代码.

谢谢大家

android illegalargumentexception

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

无法在 Google Play Console 中开启定时发布模式

我想将 Google Play Console 中的应用更新为定时发布模式。但我无法打开它。找不到时间发布开关。对此有什么想法吗?

我的 Play 管理中心

android publish google-play-console

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

反应:读取作为history.push中的参数传递的数据

我是新手,我正在尝试将一些数据作为参数发送到history.push.

基本上,我在单击按钮时调用一个方法,并在该方法内调用一个 api。如果我收到成功响应,我将重定向到其他页面,并且还需要传递一些数据。

下面是我的代码:

class Login extends Component  {

  constructor(props) {
    super(props);
    this.state = {
      enteredName: null,
      enteredPwd: null,
      rescode: null,
      userName: null,
      formatDesc: null,
      userFormat : null,
      success: false,
      responseJson : null,
    };
  }

  state = {
    enteredName: null,
    enteredPwd: null,
    rescode: null,
    userName: null,
    formatDesc: null,
    userFormat : null,
    success: false,
    responseJson : null,
  }
    render=() =>{

        return (
          <Router>
          <div id= "login-page">
            <div className="back-image" style={{height:"100vh"}}>
              <div className="container">
                <form className="form-login" action="index.html">
                  <h2 className="form-login-heading">sign in now</h2>
                  <div …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router react-router-v4 react-router-dom react-16

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

在Android OS销毁服务时删除通知

我创建了一个应用程序,它在Service.onStartCommand()执行方法时显示Notification,并在Service.onDestroy()调用时隐藏通知.它适用于正常调用startService()和stopService().

服务代码:

@Override
public IBinder onBind(Intent intent) 
{
    return null;
}
@Override
public void onCreate() 
{
    super.onCreate();
    nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
    //Some  code here
    showNotification();
    return START_NOT_STICKY; 
}

@Override
public void onDestroy() 
{
    super.onDestroy();
    nm.cancel(R.string.service_started);
}
Run Code Online (Sandbox Code Playgroud)

问题:当我的服务被android OS()销毁时(如果onDestroy()没有被调用),则通知不会被删除.那么当Android OS本身销毁Service时如何删除通知?

service android android-ondestroy

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

退出代码为1的处理完成:AVD名称未知

当我尝试运行模拟器时,出现以下错误消息:

模拟器:模拟器:错误:未知的AVD名称[Nexus_5X_API_27],请使用-list-avds查看有效列表。

模拟器:进程完成,退出代码为1

鉴于我刚刚创建了avd,能否帮助我理解为什么找不到它以及如何解决此问题?

提前致谢

android android-virtual-device android-emulator

8
推荐指数
2
解决办法
5901
查看次数