Tools - AddView Widget

/*

  *
  * if you use in mainactivity use:
  * return this.getWindow().getDecorView().findViewById(android.R.id.content);
  *
  */


final Button mybtn = new Button(this);
mybtn.setText("Your Button");
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);


#Add
((ViewGroup) getActivityContentView()).addView(mybtn, layoutParams);

#Remove
((ViewGroup) getActivityContentView()).removeView(mybtn);

}
public View getActivityContentView() {
try {
return ((Activity) getContext()).getWindow().getDecorView().findViewById(android.R.id.content);
} catch(ClassCastException e) {
throw new ClassCastException("Please provide an Activity context for this FloatingActionButton.");
}
}{

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation