How to fix this error in java?

public class Link extends AndroidNonvisibleComponent
{
    public Activity activity;
    private ComponentContainer container;
    public Context context;
    
    public LabelLink(ComponentContainer container) {  
    super(container.$form());
    this.container = container;
  }

Change Class name of Link to LabelLink
or
Change name of constructor LabelLink to Link

add this error

│  ERR src\com\sgview\link\Link.java:17: error: class LabelLink is public, should be declared in a file named LabelLink.java
│       public class LabelLink extends AndroidNonvisibleComponent{
│              ^
│
│  ERR src\com\sgview\link\Link.java:31: error: cannot find symbol
│               Link.addLinks((TextView)androidViewComponent.getView(), l);
│                                                                       ^
│         symbol:   variable l
│         location: class LabelLink
│
│  ERR src\com\sgview\link\Link.java:31: error: cannot access Link
│               Link.addLinks((TextView)androidViewComponent.getView(), l);
│               ^
│         bad source file: D:\Rush\link\src\com\sgview\link\Link.java
│           file does not contain class com.sgview.link.Link
│
│  Total errors: 3
└ Failed
1 Like

Share your code also change packge name and file name too

package com.sgview.link;

import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.errors.YailRuntimeError;
import com.google.appinventor.components.runtime.util.YailList;

import android.text.util.Linkify;
import android.widget.TextView;
import com.google.appinventor.components.runtime.AndroidViewComponent;
import android.content.Context;
import android.app.Activity;
import com.google.appinventor.components.common.ComponentCategory;

where is the function Link.addLink?

Thank you for the help, I have successfully fixed the error

1 Like