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, LinearLayout.LayoutParams.WRAP_CONTENT));
edittext1.setHint("Email");

ii. Use another add source directly block and use codes to define edittext2, set it's LayoutParams, set it's hint, set it's InputType and set it's text color.
edittext2 = new EditText(this);
edittext2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
edittext2.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
edittext2.setHint("Password");

iii. Use another add source directly block and use codes to define a TextInputLayout textinput1, set it's LayoutParams, add edittext1 to textinput1, and add textinput1 to linear2.
android.support.design.widget.TextInputLayout textinput1 = new android.support.design.widget.TextInputLayout(this);
textinput1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

textinput1.addView(edittext1);
linear2.addView(textinput1);

iv. Use another add source directly block and use codes to define another TextInputLayout textinput2, set it's LayoutParams, add edittext2 to textinput2, and add textinput2 to linear3.
android.support.design.widget.TextInputLayout textinput2 = new android.support.design.widget.TextInputLayout(this);

textinput2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

textinput2.addView(edittext2);
linear3.addView(textinput2);

5. Create two String variables email and password.


6. In the event button1 onClick, use codes to set the value of String variables to the text in EditText fields, and use the String variables in blocks to do operations on contents of the EditText fields.
email = edittext1.getText().toString();
password = edittext2.getText().toString();

7. Save and run the project.

Comments

  1. What to do?
    This error is showing !!

    1. ERROR in /storage/emulated/0/.sketchware/
    mysc/610/app/src/main/java/com/my/newproject3/
    MainActivity.java (at line 68)
    android.support.design.widget. TextInputLayout
    extinput1 = new
    android.support.design.widget. TextInputLayout(this);
    AAAAAAAAAAAAAAA
    android.support cannot be resolved to a type

    ReplyDelete
  2. How to add show/hide password button in textinputlayout ?

    ReplyDelete
  3. Hello sir, thanks for making tutorials so intuitive and useful.
    How can a ProgressDialog be used together with a WebView?
    code:

    ProgressDialog dialog = new ProgressDialog (this);
    dialog.setTitle ("Title");
    dialog.setMessage ("Message");
    dialog.setProgressStyle (ProgressDialog.STYLE_SPINNER);

    dialog.show ();

    ReplyDelete
  4. Error in /storage/emulated/0/.sketchware/mysc/613/app/scr/main/java/com/my/newproyect6/MainActivity.java (at line 109 )

    EditText edittext1, edittext2;
    ^^^^^^^^^
    Duplicate field MainActivity.edittext2

    ReplyDelete
    Replies
    1. The person above did not have app compact and design switched on...it had the kind of same error try it

      Delete
  5. Legend, keep-up the good work :)

    ReplyDelete
  6. how to change the color of the hint text???

    ReplyDelete
  7. how can i make a sticker injector in my poster maker app

    ReplyDelete
  8. Holaa q as ago for q when I register the name appears with the q I registered in another activity. Thanks, I hope your answers

    ReplyDelete
  9. /storage/emulated/0/.sketchware/mysc/620/ app/src/main/res/layout/dissc.xml:38: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/pp1'), /storage/ emulated/0/.sketchware/mysc/620/app/src/main/ res/layout/dissc.xml:57: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/pp1'), , /storage/emulated/0/.sketchware/ mysc/620/app/src/main/res/layout/groupe.xml: 22: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/pp1'), ,/ storage/emulated/0/.sketchware/mysc/620/app/src/ main/res/layout/image.xml:8: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/pp1'), , /storage/emulated/0/.sketchware/ mysc/620/app/src/main/res/layout/login2.xml: 16: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/signin')., , / storage/emulated/0/.sketchware/mysc/620/app/src/ main/res/layout/main.xml:63: error: Error: No resource found that matches the given name (at 'src' with value @drawable/pp1')., , /storage/emulated/0/.sketchware/ mysc/620/app/src/main/res/layout/user.xml:8: error: Error: No resource found that matches the given name (at 'background' with value @drawable/spl),,/ storage/emulated/0/.sketchware/mysc/620/app/src/ main/res/layout/vgp.xml:15: error: Error: No resource found that matches the given name (at 'src' with value @drawable/pp1'), . /storage/emulated/0/.sketchware/ mysc/620/app/src/main/res/layout/vue.xml:69: error: Error: No resource found that matches the given name (at 'src' with value @drawable/pp1').,] wgar how solve that?

    ReplyDelete

Post a Comment

Popular posts from this blog

A Flash Light App in Sketchware

Create Music Player app in Sketchware

Simple car racing android game in Sketchware

In Sketchware: How to create a calculator for any simple formula?

Firebase auth in Sketchware for Login Activity