小编dia*_*viu的帖子

片段错误:"已经管理了ID为0的GoogleApiClient"

一切正常,如果你第二次发现你看到这个错误:

FATAL EXCEPTION: main
Process: ro.vrt.videoplayerstreaming, PID: 23662
java.lang.IllegalStateException: Already managing a GoogleApiClient with id 0
   at com.google.android.gms.common.internal.zzx.zza(Unknown Source)
   at com.google.android.gms.common.api.internal.zzw.zza(Unknown Source)
   at com.google.android.gms.common.api.GoogleApiClient$Builder.zza(Unknown Source)
   at com.google.android.gms.common.api.GoogleApiClient$Builder.zze(Unknown Source)
   at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source)
   at ro.vrt.videoplayerstreaming.Login.onCreateView(Login.java:75)
   at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
   at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
   at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
   at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5849)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:763)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

public class Login extends Fragment implements
        GoogleApiClient.OnConnectionFailedListener,
        View.OnClickListener {

    private static final String TAG = "SignInActivity";
    private static final …
Run Code Online (Sandbox Code Playgroud)

java android android-fragments

59
推荐指数
5
解决办法
3万
查看次数

AndroidX 导航抽屉

在搜索和搜索之后,我无法向 AndroidX 迈出完整的一步。我有导航抽屉的问题。

<android.support.design.internal.BottomNavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main_page"
    app:menu="@menu/activity_main_page_drawer" />
Run Code Online (Sandbox Code Playgroud)

我已将导航视图更改为底部导航视图。

    //NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    BottomNavigationView bottomNavView = (BottomNavigationView) findViewById(R.id.nav_view);
    bottomNavView.setNavigationItemSelectedListener(this);
    View headerView = bottomNavView.getHeaderView(0);
    TextView navUsername = (TextView) headerView.findViewById(R.id.textnav);
    navUsername.setText(str);


public class MainPageActivity extends AppCompatActivity
    implements BottomNavigationView.OnNavigationItemSelectedListener {
Run Code Online (Sandbox Code Playgroud)

但我不明白它的工作。现在出现其他错误,

错误:

找不到符号方法 setNavigationItemSelectedListener(MainPageActivity) bottomNavView.setNavigationItemSelectedListener(this); ^ 符号:方法 setNavigationItemSelectedListener(MainPageActivity) 找不到符号方法 getHeaderView(int) View headerView = bottomNavView.getHeaderView(0); ^ 符号:方法 getHeaderView(int)

我该如何解决所有这些错误?

java android android-studio navigation-drawer androidx

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

PDF-LIB 从现有 PDF 添加文本和图像

我无法统一多个 pdf-lib 示例来为我工作。我想要执行与在现有 PDF 中添加文本和图像相同的功能。它总是给我错误,我不明白为什么。

const { degrees, PDFDocument, rgb, StandardFonts } = PDFLib

async function modifyPdf() {

  
  // Fetch an existing PDF document
  const url = 'https://pdf-lib.js.org/assets/with_update_sections.pdf'
  const existingPdfBytes = await fetch(url).then(res => res.arrayBuffer());

  

  // Embed the Helvetica font
  const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica);

  // Get the first page of the document
  const pages = pdfDoc.getPages();
  const firstPage = pages[0];
  
  // Fetch JPEG image
  const jpgUrl = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg';
  const jpgImageBytes = await fetch(jpgUrl).then((res) => res.arrayBuffer());
  
  // Load a PDFDocument …
Run Code Online (Sandbox Code Playgroud)

javascript

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

从类字符串中打开一个新活动.类null

在一个片段中我想打开一个新活动,但是类是由字符串提取的.在toast中接收myclass.class,但是没有打开一个新类,如果从新类中更改"c",则代码可以正常工作.谢谢.

码:

if (item instanceof Movie) {
            Log.d(TAG, "Item: " + item.toString());
            String page = item.toString();
            String pageFinal = page + ".class";
            Toast.makeText(getActivity(), item.toString(),
                    Toast.LENGTH_LONG).show();

            Class<?> c = null;
            if(pageFinal != null) {
                try {
                    c = Class.forName(pageFinal);
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
            }
            Intent intent = new Intent(getActivity(), c);
            getActivity().startActivity(intent);

        }
Run Code Online (Sandbox Code Playgroud)

日志:

    03-07 08:42:19.872 18138-18138/ro.vrt.videoplayerstreaming W/System.err:            Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
03-07 08:42:19.872 18138-18138/ro.vrt.videoplayerstreaming D/AndroidRuntime: Shutting down …
Run Code Online (Sandbox Code Playgroud)

android

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