Postingan
Menampilkan postingan dengan label Widget Code
Widget - Create Textview
- Dapatkan link
- X
- Aplikasi Lainnya
final TextView mytext = new TextView(ProjectinActivity.this); mytext.setText("Your Text"); mytext.setTextColor(0xFF000000); mytext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylinear.addView(mytext);
Widget - DatePicker
- Dapatkan link
- X
- Aplikasi Lainnya
DatePicker dp=new DatePicker(MainActivity.this); linear1.addView(dp); Calendar calendar = Calendar.getInstance(); dp.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH),new DatePicker.OnDateChangedListener(){ @Override public void onDateChanged(DatePicker datePicker, int i, int i1, int i2) { Toast.makeText(getApplicationContext(),datePicker.getDayOfMonth() + "-" +datePicker.getMonth() + "-"+datePicker.getYear(),Toast.LENGTH_SHORT).show(); } });
Widget - Dialog Choose
- Dapatkan link
- X
- Aplikasi Lainnya
AlertDialog.Builder builderSingle = new AlertDialog.Builder(MainActivity.this); builderSingle.setIcon(R.drawable.ic_launcher); builderSingle.setTitle("Select One Name:-"); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.select_dialog_singlechoice); arrayAdapter.add("Hardik"); arrayAdapter.add("Archit"); arrayAdapter.add("Jignesh"); arrayAdapter.add("Umang"); arrayAdapter.add("Gatti"); builderSingle.setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override ...
Widget - Dialog Custome
- Dapatkan link
- X
- Aplikasi Lainnya
final AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create(); LayoutInflater inflater = getLayoutInflater(); View convertView = (View) inflater.inflate(R.layout.custom_dialog, null); dialog.setView(convertView); TextView txt1 = (TextView) convertView.findViewById(R.id.textview1);//on custome_dialog txt1.setText("your text here!"); Button btn1 = (Button) convertView.findViewById(R.id.button1);//on custome_dialog btn1.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ dialog.dismiss(); showMessage("Aan"); } }); dialog.show();
Widget - Dialog Edittext
- Dapatkan link
- X
- Aplikasi Lainnya
LinearLayout mylayout = new LinearLayout(MainActivity.this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mylayout.setLayoutParams(params); mylayout.setOrientation(LinearLayout.VERTICAL); final EditText myedittext = new EditText(MainActivity.this); myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylayout.addView(myedittext); dialog.setView(mylayout); myedittext.setHint("Enter your name");
Widget - Dialog Theme
- Dapatkan link
- X
- Aplikasi Lainnya
//GingerBread dialog = new AlertDialog.Builder(this,AlertDialog.THEME_TRADITIONAL); //Holo Dark dialog = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_DARK); //Holo Light dialog = new AlertDialog.Builder(this,AlertDialog.THEME_HOLO_LIGHT); //Material Dark setTheme(android.R.style.Theme_Material); //Material Light setTheme(android.R.style.Theme_Material_Light); //Default Dark dialog = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_DARK); //Default light dialog = new AlertDialog.Builder(this,AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
Widget - Dialog CheckBox
- Dapatkan link
- X
- Aplikasi Lainnya
private int checkedItem = 0; new android.support.v7.app.AlertDialog.Builder(MainActivity.this).setTitle("Shape Type").setSingleChoiceItems( new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }, checkedItem, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { checkedItem = which; switch (which) { case 0: showMessage("0"); dialog.dismiss(); break; case 1: showMessage("1"); dialog.dismiss(); break; case 2: showMessage("2"); dialog.dismiss(); break; case 3: showMessage("3"); dialog.dismiss(); break; default: dialog.dismiss(); break; } } }).show();
Widget - Drag Widget
- Dapatkan link
- X
- Aplikasi Lainnya
img.setOnTouchListener(new OnTouchListener() { PointF DownPT = new PointF(); PointF StartPT = new PointF(); @Override public boolean onTouch(View v, MotionEvent event) { int eid = event.getAction(); switch (eid) { case MotionEvent.ACTION_MOVE: PointF mv = new PointF(event.getX() - DownPT.x, event.getY() - DownPT.y); img.setX((int)(StartPT.x+mv.x)); img.setY((int)(StartPT.y+mv.y)); StartPT = new PointF(img.getX(), img.getY()); break; case MotionEvent.ACTION_DOWN: DownPT.x = event.getX(); DownPT.y = event.getY(); StartPT = new PointF(img.getX(), img.getY()); break; case MotionEvent.ACTION_UP: float distance = DownPT.x - event.getX(); if (distance == 0) { showMessage("Clicked"); } break; default : break; } return true; } });
Widget - DrawerLayout
- Dapatkan link
- X
- Aplikasi Lainnya
final android.support.v4.widget.DrawerLayout drawer = new android.support.v4.widget.DrawerLayout(this); final android.support.v4.widget.DrawerLayout drawer1 = new android.support.v4.widget.DrawerLayout(this); //main.xml is MainActivity LinearLayout innerView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.main, null); //create xml file with name "menu" LinearLayout slideView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.menu, null); android.support.v4.widget.DrawerLayout.LayoutParams lp1 = new android.support.v4.widget.DrawerLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT , LinearLayout.LayoutParams.MATCH_PARENT); android.support.v4.widget.DrawerLayout.LayoutParams lp = new android.support.v4.widget.DrawerLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT , LinearLayout.LayoutParams.MATCH_PARENT); android.widget.FrameLayout.LayoutParams fl = new android.widget.FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGrou...
Widget - Edittext Disable Sugestion (single line)
- Dapatkan link
- X
- Aplikasi Lainnya
Cara pembuatan Apps paling Populer
Create Stopwatch App in Android using Sketchware
Timer component and number variables can be used to add a Stopwatch to your Android App created in Sketchware. To create a Stopwatch App in Sketchware follow the steps below. 1. Start a new project in Sketchware . Fill app name, package name and app icon. 2. In VIEW area, insert a Textview and a Button widget. In Textview properties set layout_gravity as center_horizontal, text as 00:00:00.00, and text_size as 40sp. In Button properties set layout_gravity as center_horizontal, text as Start/Stop/Reset and text_size as 20sp. 3. In LOGIC area add a new timer component t . 4. In onCreate event, add five number variables , one each for hour, minutes, seconds, and milliseconds, and an extra variable for managing Button Click. Set all these number variables to 0. 5. Suppose the five number variables are named as h , m ,...
TextInputLayout in Sketchware
To create an EditText with animation features, we can use the EditText in a TextInputLayout which is a Layout interface in android.support.design.widget library. In Sketchware we cannot add it in xml file but we can create it programmatically. Follow the instructions given below for a simple example. 1. In VIEW area of your project add two Linear horizontal linear2 and linear3 , and a Button button1 . 2. Switch On AppCompat and design. 3. Create a more block extra and define the block using an add source directly block. Put following code in it. } EditText edittext1, edittext2; { Here we declare two EditText fields, edittext1 and edittext2 . 4. In onCreate event, i. Use add source directly block and use codes to define edittext1, set it's LayoutParams, set it's hint, and set it's text color. edittext1 = new EditText(this); edittext1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayou...
How to find and highlight a word in a text field in Sketchware?
We can highlight a particular searched character sequence in a TextView or EditText field or any other text field by using Spannable. To use Spannable class to highlight a searched text in Sketchware Android Project, follow the steps given below. 1. In VIEW area of your project, add an EditText field ( edittext1 ) which will act as input field for search term. Add a TextView ( textview1 ) which will display the number of results found. And add another TextView ( textview2 ) or EditText (edittext2) field which will contain the text in which the word is to be searched. 2. In LOGIC area, in onCreate event set the text to be searched in TextView field. 3. If you want the app to search from any text added by user, use EditText instead textview2 in step no.1 and do not set the text in onCreate. 4. Add a new String variable text . Add three number variables total, len and y . 4. Add a new event edittext1 onTextChanged . 5. In the event edittext1 onTextChange...
A Flash Light App in Sketchware
To create a Torch Flashlight application for Android with Sketchware follow the steps given below. 1. Create a new project in Sketchware. In VIEW area add an ImageView imageview1 . Set it's width and height to 100, and scale type to FIT_XY. 2. Using Image Manager add two images ic_flash_on_black and ic_flash_off_black . 3. Set ic_flash_off_black as the image of imageview1. 4. In Library manager switch on AppCompat and Design . 5. Add a Camera component . 6. Add two Boolean variables: flashLightStatus and hasCameraFlash . 7. Add two More Blocks: flashLightOn and flashLightOff . 8. In onCreate event, use add source directly block and put following code: hasCameraFlash = getPackageManager(). hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); 9. In More Block flashLightOn , use add source directly block and put following code: android.hardware.camera2.CameraManager cameraManager = (andr...
How to enable download in webview in Sketchware apps?
How to enable download in an app created with Sketchware? Suppose you have created an app in Sketchware which uses webview to open a site. You can seamlessly explore the site in your app. But the download links in the webview field do not work. But it is possible to make it work by exporting the source code. You can edit the code in either Android studio or Eclipse to add your desired features and then recompile it. I tried to do that but soon realized that setting up environment for development of Android app is not easy for a naive like me. But it can be done by code injection or by using another mobile app called Anacode. Enabling download from webview in Sketchware using add source directly block. 1. In VIEW area of your app insert a WebView (webview1). 2. In LOGIC area, in onCreate event, a. Add write String... to file path ... Block. This will add WRITE_EXTERNAL_STORAGE permission. b. Then add an add source directly block. In this block pu...
Intent - Open File By Type
java.io.File _PathOpenFile = Environment.getExternalStorageDirectory(); java.io.File myFile = new java.io.File(_PathOpenFile + "/aan.zip"); java.io.File url = myFile; Uri uri = Uri.fromFile(url); Intent intent = new Intent(Intent.ACTION_VIEW); if (url.toString().contains(".doc") || url.toString().contains(".docx")) { intent.setDataAndType(uri, "application/msword"); } else if(url.toString().contains(".pdf")) { intent.setDataAndType(uri, "application/pdf"); } else if(url.toString().contains(".ppt") || url.toString().contains(".pptx")) { intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if(url.toString().contains(".xls") || url.toString().contains(".xlsx")) { intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if(url.toString().contains(".zip") || url.toString().contains(".rar")) { intent.setDataAndType(uri, "applica...
Code for implementing Notifications in Sketchware
This tutorial shows a Sketchware android project example in which a Notification is displayed when a Button is clicked and when the Notification is clicked, it opens a new Activity. 1. Create a new project in Sketchware. In VIEW area add an EditText edittext1 , and a Button button1 . 2. Using Image Manager add an images mail_white . This will be used as the Notification icon. 3. In Library manager switch on AppCompat and Design . 4. Create a new VIEW two.xml / TwoActivity.java . 5. Add a More Block: createChannel . 6. In More Block createChannel , use add source directly block and put following code: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = "Channel name 1"; String description = "Notification channel"; int importance = NotificationManager.IMPORTANCE_DEFAULT; NotificationChannel channel = new NotificationChannel("id 1", name, importance); channel.setDescription(description); NotificationManager not...
How to share an image from Drawable folder?
To share an image in drawable folder of your sketchware android project, first save the image in app cache and then share the saved image using it's Uri. The code to be used is provided below. 1. First add the image (my_image.jpg) to be shared in your Sketchware android project using image manager. 2. Add a Button button1 which will act as share button. 3. In event button1 onClick, use add source directly block and add following code: Bitmap bitmap= BitmapFactory.decodeResource(getResources(),R.drawable.my_image); String path = getExternalCacheDir()+"/shareimage.jpg"; java.io.OutputStream out = null; java.io.File file=new java.io.File(path); try { out = new java.io.FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } path=file.getPath(); Uri bmpUri = Uri.parse("file://"+path); Intent shareIntent = new Intent(); shareIntent = new Intent(android.content.Intent.ACTION...
ActionBar back button
Animation Transtition Animation
/*this will go in button click, activity start, or whatever*/ android.transition.TransitionManager.beginDelayedTransition(linear1,makeFadeTransition()); toggleVisibility(imageview1,imageview2,imageview3,imageview4); android.transition.TransitionManager.beginDelayedTransition(linear1,makeSlideTransition()); toggleVisibility(imageview1,imageview2,imageview3,imageview4); android.transition.TransitionManager.beginDelayedTransition(linear1,makeExplodeTransition()); toggleVisibility(imageview1,imageview2,imageview3,imageview4); /*This stays at the bottom of all code in onCreate*/ } private android.transition.Fade makeFadeTransition(){ android.transition.Fade fade = new android.transition.Fade(); fade.setDuration(2000); fade.setInterpolator(new AnticipateInterpolator()); return fade; } private android.transition.Slide makeSlideTransition(){ android.transition.Slide slide = new android.transition.Slide(); slide.setSlideEdge(Gravity.TOP); slide.setInterpolator(new BounceInterpolator()); slide.s...