I create this guide on the demand of @SRIKAR_B.S.S
I this guide we learn how to set text and color of Button
As I told you in my first guide that to create any extension first of all we need import so in this extension we set text and text color of button so, first of we need import of button. You can get import of button from my first guide
Import of button
import android.widget.Button;
Code for set text and color of button
import android.app.Activity;
import android.content.Context;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.HVArrangement;
import android.widget.FrameLayout;
import android.widget.Button;
import android.view.View;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
private Activity activity;
private Context context;
private Button button;
@SimpleFunction(description = "1")
public void Create(HVArrangement arrangement) {
button = new Button(context);
View view = arrangement.getView();
FrameLayout frameLayout = (FrameLayout) view;
frameLayout.addView(button, new FrameLayout.LayoutParams(-1, -1));
}
@SimpleProperty(description = "2")
public void Text(String text) {
button.setText(text);
}
@SimpleProperty(description = "3")
public Object Text() {
Object text = button.getText();
return text;
}
@SimpleProperty(description = "4")
public void TextColor(String color) {
button.setTextColor(Color.parseColor(color));
}
- Usefull
- Not Usefull
0 voters
If you like this guide then click the like button