Please Help - To fix my Extension!

Please Help - To fix my Extension!

I have try make an extension …
This code :slight_smile:

package com.myex.SpanText;

import com.google.appinventor.components.runtime.util.WordToSpan;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;

import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@DesignerComponent(version = 1,
description =“A SpanText Extension”,
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = “images/extension.png”)
@SimpleObject(external = true)

public class SpanText extends AndroidNonvisibleComponent {

public static final int VERSION = 1;
private ComponentContainer container;

private String myText;
private String keyWord;
private TextView tv;


public SpanText(ComponentContainer container) {
    super(container.$form());
    this.container = container;
}

	
@SimpleFunction(description = "  Set Text  WordToSpan")
public void highlight(String myText,String keyWord  ){ 

	WordToSpan highlight = new WordToSpan();	
    highlight.setBackgroundHIGHLIGHT(Color.YELLOW)
	.setColorHIGHLIGHT(Color.RED)
    .setHighlight(myText, keyWord)
    .setUnderlineTAG(true)
    .into(tv);
    }

}

I get error no such class : com.myex.SpanText.SpanText
if build app :frowning_face:

Library WordtoSpan WordToSpan.txt (8.8 KB)

source GitHub - bachors/Android-WordToSpan: Small & simple library to create a link url, mail, mention, tag and text highlighter in textView.

the first thing put your java files in the same folder with the same package name and check

i have make like this:
com/myex/SpanText/SpanText.java

i thing correct :slight_smile:

1 Like

or maybe false :frowning_face:

or like that:
com/myex/SpanText.java

?

Put both files in the same directory:
com/myex/SpanText/SpanText.java
com/myex/SpanText/WordToSpan.java

and inside the both file put the same package name: package co.com.myex.SpanText;

2 Likes

Ok tomorow i try again :slight_smile:
thanks sir @Said_Dev :blush:

its correct :thinking: sir?

package co.com.myex.SpanText;

Stiil error sir :sob:

i think this false ?

private String myText;
private String keyWord;
private TextView tv;

how to be work like this:

String myText = “Any code and resources in the Android library anywhere love code.”;
String keyWord = “any code”;
TextView tv = (TextView)findViewById(R.id.tx);

TextView tv = new TextView(context);

2 Likes

sir ,i get error with variable context :confused:
i hve add

import android.content.Context;

still error ?
why :thinking:

Your constructor should be

public SpanText(ComponentContainer container) {
    super(container.$form());
    this.container = container;
    context = (Context) container.$context();
} 

Then you can use context

1 Like

Thank you sir @Red_Panda :wink:
i will try again … :slight_smile:

This late my code :

package com.myext.spantext;

import com.myext.spantext.WordToSpan;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;


import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import android.content.Context;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@DesignerComponent(version = 1,
        description ="A SpanText Extension",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "images/extension.png")
@SimpleObject(external = true)

public class SpanText extends AndroidNonvisibleComponent {	

    public static final int VERSION = 1;
    private ComponentContainer container;
	
	private String myText;
	private String keyWord;
	private TextView tv;
    

    public SpanText(ComponentContainer container) {
        super(container.$form());
        this.container = container;
        context = (Context) container.$context();
	}
	
		
	@SimpleFunction(description = "  Set Text  WordToSpan")
	public void highlight(String myText,String keyWord  ){ 
	
		TextView tv = new TextView(context);
		WordToSpan highlight = new WordToSpan();	
        highlight.setBackgroundHIGHLIGHT(Color.YELLOW)
		.setColorHIGHLIGHT(Color.RED)
	    .setHighlight(myText, keyWord)
	    .setUnderlineTAG(true)
	    .into(tv);
        }
	
}

But still error :cry:

[javac] D:\AI\appinventor-sources\appinventorExtension\components\src\com\myext\spantext\SpanText.java:57: error: cannot find symbol
[javac] context = (Context) container.$context();
[javac] ^
[javac] symbol: variable context
[javac] location: class SpanText
[javac] D:\AI\appinventor-sources\appinventorExtension\components\src\com\myext\spantext\SpanText.java:64: error: cannot find symbol
[javac] TextView tv = new TextView(context);
[javac] ^
[javac] symbol: variable context
[javac] location: class SpanText
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
[javac] 1 warning

BUILD FAILED

:confounded:

You are missing the declaration, it should be like this

package com.myext.spantext;

import com.myext.spantext.WordToSpan;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;


import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import android.content.Context;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@DesignerComponent(version = 1,
        description ="A SpanText Extension",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "images/extension.png")
@SimpleObject(external = true)

public class SpanText extends AndroidNonvisibleComponent {	

    public static final int VERSION = 1;
    private Context context;
    private ComponentContainer container;
    private String myText;
    private String keyWord;
    private TextView tv;
    

    public SpanText(ComponentContainer container) {
        super(container.$form());
        this.container = container;
        context = (Context) container.$context();
	}
	
		
	@SimpleFunction(description = "  Set Text  WordToSpan")
	public void highlight(String myText,String keyWord  ){ 
	
		TextView tv = new TextView(context);
		WordToSpan highlight = new WordToSpan();	
        highlight.setBackgroundHIGHLIGHT(Color.YELLOW)
		.setColorHIGHLIGHT(Color.RED)
	    .setHighlight(myText, keyWord)
	    .setUnderlineTAG(true)
	    .into(tv);
        }
	
}
3 Likes

Thanks sir :slight_smile:
wait i trying …

Stiil Error to build app sir :sob:

this aix n my sample aia :
com.myext.spantext.aix (2.7 KB)
Kwsearch.aia (21.3 KB)

Please help me :slight_smile:

The aix link is not working, it’s empty :frowning:

Im test link work via android :thinking:

Sir @Said_Dev @Red_Panda

or maybe my extension is not visible component :thinking:

and isnot component like textbox ??

so get error :thinking:

and i think …this need function implementation to component textview/textbox

(sorry my english is 0.5) :sweat_smile:

How to do its sir :thinking:

:pray:

send me the file java i will check for you

1 Like