Posts

Showing posts from February, 2020

How to create Swipe to Refresh in Sketchware using Androidx

Image
The code used is: final androidx.swiperefreshlayout.widget.SwipeRefreshLayout  sr = new androidx.swiperefreshlayout.widget.SwipeRefreshLayout (this); sr.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); linear1.addView(sr); final WebView wb = (WebView)findViewById(R.id.webview1); wb.getSettings().setJavaScriptEnabled(true); linear1.removeView(wb); linear1.post(new Runnable() { @Override public void run() { sr.addView(wb); } }); wb.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { sr.setRefreshing(false); }}); sr.setOnRefreshListener( new androidx.swiperefreshlayout.widget.SwipeRefreshLayout .OnRefreshListener() { @Override public void onRefresh() { wb.reload(); } } ); The tutorial video related to it:

How to Create Snackbar in Sketchware using Androidx

Image
The code used is: //default button value String ButtonText = "OK"; //Custom button text ButtonText = _buttonText; //Snackbar code ViewGroup parentLayout = (ViewGroup) ((ViewGroup) this .findViewById(android.R.id.content)).getChildAt(0); com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(parentLayout, _message, com.google.android.material.snackbar.Snackbar.LENGTH_INDEFINITE).setAction(ButtonText, new View.OnClickListener() {  @Override public void onClick(View view) { } }); //Setting duration snackbar.setDuration((int)_duration*1000); //Snackbar show snackbar.show(); The tutorial video for this is:

How to create BottomSheet dialog in Sketchware using Androidx

Image
The code is: final com.google.android.material.bottomsheet.BottomSheetDialog bs_base = new com.google.android.material.bottomsheet.BottomSheetDialog(MainActivity.this); View layBase = getLayoutInflater().inflate(R.layout.cust, null); bs_base.setContentView(layBase); bs_base.show(); Button pay_bs = (Button)layBase.findViewById(R.id.button1); pay_bs.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { bs_base.dismiss(); showMessage("Payment Done"); } }); The tutorial video is:

Determine Screen Size in Sketchware

Image
The code is: Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics (); display.getMetrics(outMetrics); float density = getResources().getDisplayMetrics().density; float height = outMetrics.heightPixels / density; float width = outMetrics.widthPixels / density;

How to create Custom Dialog in Sketchware

Image
The code used: final AlertDialog dialog2 = new AlertDialog.Builder(MainActivity.this).create(); View inflate = getLayoutInflater().inflate(R.layout.dialog, null); dialog2.setView(inflate); dialog2.getWindow().setBackgroundDrawableResource(android.R.color.transparent); final Button but1 = (Button) inflate.findViewById(R.id.button1); final Button but2 = (Button) inflate.findViewById(R.id.button2); final LinearLayout lin1 = (LinearLayout) inflate.findViewById(R.id.linear2); _gd(lin1, "#FFFFFF", "#2196F3", 25); _setCornerRadius(but1, 100, "#2196F3"); _setCornerRadius(but2, 100, "#1976D2"); but1.setOnClickListener(new OnClickListener() { public void onClick(View view) { MainActivity.this.finish(); } }); but2.setOnClickListener(new OnClickListener() { public void onClick(View view) { dialog2.dismiss(); } }); dialog2.show(); A tutorial video is below:

How to create Phone OTP Authentication in Sketchware

Image
Code for send otp : com.google.firebase.auth.PhoneAuthProvider.getInstance().verifyPhoneNumber(                 phoneNumber,                  (long)60, java.util.concurrent.TimeUnit.SECONDS, MainActivity.this,               mCallback     ); Code for Moreblock : } com.google.firebase.auth.PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallback = new com.google.firebase.auth.PhoneAuthProvider.OnVerificationStateChangedCallbacks() {                 @Override         public void onVerificationCompleted(com.google.firebase.auth.PhoneAuthCredential phoneAuthCredential) {             Toast.makeText(MainActivity.this,"Code Received",Toast.LENGTH_SHORT).show();         }         @Override         public void onVerificationFailed(com.google.firebase.FirebaseException e) {            //if verification failed Toast.makeText(MainActivity.this,"verification fialed",Toast.LENGTH_SHORT).show();         }         @Override         public void onCo