Postingan

Menampilkan postingan dengan label Widget Code

Widget - CheckBox Image

checkbox1.setButtonDrawable(r.drawable.iconname);

Widget - Create Button

final Button mybutton = new Button(ProjectinActivity.this); mybutton.setText("Your Button"); mybutton.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylinear.addView(mybutton);

Widget - Create Edittext

final EditText myedit = new EditText(ProjectinActivity.this); myedit.setHint("Your Hint"); myedit.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylinear.addView(myedit);

Widget - Create Textview

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

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 Cancellable

mydialog.setCancelable(false);

Widget - Dialog Choose

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

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

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 Icon

yourdialog.setIcon(R.drawable.image_name)

Widget - Dialog Theme

//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

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

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

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 Border

android.graphics.drawable.ShapeDrawable shape = new android.graphics.drawable.ShapeDrawable(new android.graphics.drawable.shapes.RectShape()); shape.getPaint().setColor(Color.RED); shape.getPaint().setStyle(Paint.Style.STROKE); shape.getPaint().setStrokeWidth(3); edittext1.setBackground(shape);

Widget - Edittext Disable Sugestion

edittext1.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Widget - Edittext Disable Sugestion (single line)

edittext1.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Widget - Edittext Error

edittext1.setError("Use text Aan Gabriel");

Widget - Edittext Hints

edittext1.setHint("*Hint contents*");

Widget - Edittext Keyboard

//Enable edittext1.setShowSoftInputOnFocus(true); //Disable edittext1.setShowSoftInputOnFocus(false);

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to enable download in webview in Sketchware apps?

Create Stopwatch App in Android using Sketchware

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Codes for modifying Action Bar in Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

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

Firebase Login/Register with email verification