Skip to main content

Copy and Paste Text automatically in Sketchware


Code:

ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);


if (clipboard.hasPrimaryClip()) {

    ClipData clipData = clipboard.getPrimaryClip();

    ClipData.Item item = clipData.getItemAt(0);


    String text = item.getText().toString();


    edittext1.setText(text);

}


Comments

Popular posts from this blog

Edittext Floating Hint in Sketchware

Code  :  EditText editText = new EditText(this); LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); com.google.android.material.textfield.TextInputLayout textInputLayout = new com.google.android.material.textfield.TextInputLayout(this); LinearLayout.LayoutParams textInputLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); textInputLayout.setLayoutParams(textInputLayoutParams); textInputLayout.addView(editText, editTextParams); textInputLayout.setHint("Your Name"); // Your view Code here

Pinch-to-zoom with multi-touch gestures In Sketchware

We will demonstrate multi-touch with the common pinch-to-zoom gesture. The following screen-shot shows the icon zoomed in and out using the application created : Zoom in Zoom out Let's get started! 1. Create a new project. 2. Add an imageview widget to your view (you can use any image of your choice). 3. Create a block and name it (zoom_in_out). 4. Add this code to your block. } private ScaleGestureDetector mScaleGestureDetector; private float mScaleFactor = 1.0f; public boolean onTouchEvent(MotionEvent motionEvent) { mScaleGestureDetector.onTouchEvent(motionEvent); return true; } { } private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { @Override public boolean onScale(ScaleGestureDetector scaleGestureDetector){mScaleFactor *= scaleGestureDetector.getScaleFactor(); mScaleFactor = Math.max(0.1f,Math.min(mScaleFactor, 10.0f)); imageview1.setScaleX(mScaleFactor); imageview1.setScaleY(mScaleFactor);return true; } } { 5. Add this code to your OnCreate ...

Google Maps Intents Sketchware

Intent Intents let you start an activity in another app by describing a simple action you'd like to perform (such as "display a map" or "show directions to the airport") in an  Intent  object. The  Google Maps app for Android  supports several different intents, allowing you to launch the Google Maps app and perform one of four actions: Display a map at a specified location and zoom level. Search for locations or places, and display them on a map. Request directions from one location to another. Directions can be returned for three modes of transportation: driving, walking, bicycling. Display panorama imagery in Google Street View. This page describes the intents that you can use with Google Maps app for Android. For more information on  Intents and Intent Filters , or  Intents common to the Android platform , refer to the Android developer documentation.         Intent requests In order to launch Google Maps with an intent you must...