To create a custom Toast message in Sketchware, follow the steps given below
- This is main.xml
- Create a customview name with custom1
- Add linear1 and textview1, custom.xml as shown in the image.
- Customize the textview1 and linear1 as per your requiremen
- In LOGIC area, add a new More Block with name customToast(String _text) as shown in image below.
- Next define this customToast Block. In event customToast MoreBlock use add source directlyblock, and in the block, write codes as described below.
LayoutInflater inflater = getLayoutInflater(); View toastLayout = inflater.inflate(R.layout.custom1, null);
TextView textview1 = (TextView) toastLayout.findViewById(R.id.textview1);
textview1.setText(_text);
LinearLayout linear1 = (LinearLayout) toastLayout.findViewById(R.id.linear1);
Toast toast = new Toast(getApplicationContext()); toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(toastLayout);
toast.show();
TextView textview1 = (TextView) toastLayout.findViewById(R.id.textview1);
textview1.setText(_text);
LinearLayout linear1 = (LinearLayout) toastLayout.findViewById(R.id.linear1);
Toast toast = new Toast(getApplicationContext()); toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(toastLayout);
toast.show();
- Use the more Block whenever you want to display a custom Toast, as shown in image below.
- Now save and run
Are you like to earn money with link sharing.
You can earn per vist 0.025$.(only this referal link)
Click to register
0 Comments