Description
I can only import the Android classes in the main TextOptions.java file, but it gives an error when trying to import in TextInputWithButton.java which is in the helpers subdirectory. I found the source but the proposed solution doesn't work.
Structure
- io:
-
- textoptions:
-
-
- TextOptions.java
-
-
- helpers:
-
-
- TextInputWithButton.java
-
TextInputWithButton.java:
package io.textoptions.helpers;
import android.content.Context;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
public class TextInputWithButton extends LinearLayout {
private EditText editText;
private Button button;
public TextInputWithButton(Context context) {
super(context);
setOrientation(HORIZONTAL);
editText = new EditText(context);
button = new Button(context);
// Personalize o botão, como cor de fundo e texto, conforme necessário
button.setBackgroundColor(0xFF00FF00); // Exemplo: cor verde
button.setText("Ok"); // Exemplo: texto do botão
addView(editText);
addView(button);
}
public EditText getEditText() {
return editText;
}
public Button getButton() {
return button;
}
}
TextOptions.java:
package io.textoptions;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.provider.Settings;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.EditText;
import android.view.ViewGroup;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.errors.PermissionException;
import java.util.ArrayList;
import java.util.List;
import android.widget.Button;
import io.textoptions.helpers.TextInputWithButton;
@DesignerComponent(
version = 2,
description = "This extension displays a dialog with options to copy or share text from a Label component.",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "images/extension.png"
)
@SimpleObject(external = true)
public class TextOptions extends AndroidNonvisibleComponent {
...
}
Error
CommonConstants:
[mkdir] Created dir: /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] Compiling 42 source files to /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] warning: [options] bootstrap class path not set in conjunction with -source 7
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:6: error: cannot find symbol
[javac] public class TextInputWithButton extends LinearLayout {
[javac] ^
[javac] symbol: class LinearLayout
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:8: error: cannot find symbol
[javac] private EditText editText;
[javac] ^
[javac] symbol: class EditText
[javac] location: class TextInputWithButton
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:9: error: cannot find symbol
[javac] private Button button;
[javac] ^
[javac] symbol: class Button
[javac] location: class TextInputWithButton
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:11: error: cannot find symbol
[javac] public TextInputWithButton(Context context) {
[javac] ^
[javac] symbol: class Context
[javac] location: class TextInputWithButton
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:26: error: cannot find symbol
[javac] public EditText getEditText() {
[javac] ^
[javac] symbol: class EditText
[javac] location: class TextInputWithButton
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:30: error: cannot find symbol
[javac] public Button getButton() {
[javac] ^
[javac] symbol: class Button
[javac] location: class TextInputWithButton
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:3: error: package android.content does not exist
[javac] import android.content.*;
[javac] ^
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:4: error: package android.widget does not exist
[javac] import android.widget.*;
[javac] ^
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:13: error: cannot find symbol
[javac] setOrientation(HORIZONTAL);
[javac] ^
[javac] symbol: variable HORIZONTAL
[javac] location: class TextInputWithButton
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:15: error: cannot find symbol
[javac] editText = new EditText(context);
[javac] ^
[javac] symbol: class EditText
[javac] location: class TextInputWithButton
[javac] /home/iaiaia/Documentos/Kodular/CriarExtensoes/appinventor-sources/appinventor/components/src/io/textoptions/helpers/TextInputWithButton.java:16: error: cannot find symbol
[javac] button = new Button(context);
[javac] ^
[javac] symbol: class Button
[javac] location: class TextInputWithButton
[javac] 11 errors
[javac] 1 warning