Scrollable TabLayout in Sketchware
The example provided below shows how to create a simple scrollable TabLayout and add a TabLayout.OnTabSelectedListener to it in Sketchware.
1. In VIEW area of main.xml add a Linear Vertical linear1 with width and height as match_parent. Inside it add a Linear Horizontal linear2.
2. Switch On AppCompat and design.
3. In onCreate event, use an add source directly block and put following codes.
// Create a TabLayout (tabLayout)
android.support.design.widget.TabLayout tabLayout = new android.support.design.widget.TabLayout(this);
// Make TabLayout scrollable
tabLayout.setTabMode(android.support.design.widget.TabLayout.MODE_SCROLLABLE);
// Add Tabs to the TabLayout
tabLayout.addTab(tabLayout.newTab().setText("Sunday")); tabLayout.addTab(tabLayout.newTab().setText("Monday")); tabLayout.addTab(tabLayout.newTab().setText("Tuesday"));
tabLayout.addTab(tabLayout.newTab().setText("Wednesday")); tabLayout.addTab(tabLayout.newTab().setText("Thursday")); tabLayout.addTab(tabLayout.newTab().setText("Friday"));
tabLayout.addTab(tabLayout.newTab().setText("Saturday"));
// Add TabLayout to linear2
linear2.addView(tabLayout);
// Add OnTabSelectedListener to the TabLayout
tabLayout.addOnTabSelectedListener(new android.support.design.widget.TabLayout.OnTabSelectedListener(){
@Override
public void onTabSelected(android.support.design.widget.TabLayout.Tab tab){
switch(tab.getText().toString()){
case "Sunday":
linear1.setBackgroundColor(Color.RED);
break;
case "Monday":
linear1.setBackgroundColor(Color.parseColor("#aaddab"));
break;
case "Tuesday":
linear1.setBackgroundColor(Color.parseColor("#0dddad"));
break;
case "Wednesday":
linear1.setBackgroundColor(Color.BLUE);
break;
case "Thursday":
linear1.setBackgroundColor(Color.YELLOW);
break;
case "Friday":
linear1.setBackgroundColor(Color.WHITE);
break;
case "Saturday":
linear1.setBackgroundColor(Color.GREEN);
break;
}
}
@Override
public void onTabReselected(android.support.design.widget.TabLayout.Tab tab){
}
@Override
public void onTabUnselected(android.support.design.widget.TabLayout.Tab tab){
}
});
4. Save and run the project.
The video below shows the same.
Adding TabLayout in latest version of Sketchware:
https://www.sketchwarehelp.com/2020/02/androidx-tablayout-in-sketchware.html?m=1
1. In VIEW area of main.xml add a Linear Vertical linear1 with width and height as match_parent. Inside it add a Linear Horizontal linear2.
2. Switch On AppCompat and design.
3. In onCreate event, use an add source directly block and put following codes.
// Create a TabLayout (tabLayout)
android.support.design.widget.TabLayout tabLayout = new android.support.design.widget.TabLayout(this);
// Make TabLayout scrollable
tabLayout.setTabMode(android.support.design.widget.TabLayout.MODE_SCROLLABLE);
// Add Tabs to the TabLayout
tabLayout.addTab(tabLayout.newTab().setText("Sunday")); tabLayout.addTab(tabLayout.newTab().setText("Monday")); tabLayout.addTab(tabLayout.newTab().setText("Tuesday"));
tabLayout.addTab(tabLayout.newTab().setText("Wednesday")); tabLayout.addTab(tabLayout.newTab().setText("Thursday")); tabLayout.addTab(tabLayout.newTab().setText("Friday"));
tabLayout.addTab(tabLayout.newTab().setText("Saturday"));
// Add TabLayout to linear2
linear2.addView(tabLayout);
// Add OnTabSelectedListener to the TabLayout
tabLayout.addOnTabSelectedListener(new android.support.design.widget.TabLayout.OnTabSelectedListener(){
@Override
public void onTabSelected(android.support.design.widget.TabLayout.Tab tab){
switch(tab.getText().toString()){
case "Sunday":
linear1.setBackgroundColor(Color.RED);
break;
case "Monday":
linear1.setBackgroundColor(Color.parseColor("#aaddab"));
break;
case "Tuesday":
linear1.setBackgroundColor(Color.parseColor("#0dddad"));
break;
case "Wednesday":
linear1.setBackgroundColor(Color.BLUE);
break;
case "Thursday":
linear1.setBackgroundColor(Color.YELLOW);
break;
case "Friday":
linear1.setBackgroundColor(Color.WHITE);
break;
case "Saturday":
linear1.setBackgroundColor(Color.GREEN);
break;
}
}
@Override
public void onTabReselected(android.support.design.widget.TabLayout.Tab tab){
}
@Override
public void onTabUnselected(android.support.design.widget.TabLayout.Tab tab){
}
});
4. Save and run the project.
The video below shows the same.
Adding TabLayout in latest version of Sketchware:
https://www.sketchwarehelp.com/2020/02/androidx-tablayout-in-sketchware.html?m=1
How to create keyboard app?
ReplyDeletessa
I also want to create my own keyboard
DeleteDont possible in sk
DeleteHow to create keyboard app
ReplyDeletehttps://freetril.blogspot.com/2019/05/annabelle-comes-home.html
Dil değiştirme nasıl yapılır
ReplyDeleteNice post. Thank you for sharing the information.
ReplyDeletemoviebox application
show box
Bro does admob show ads in app made in sketchware
ReplyDeleteBro plzz tell me, does admob really show ads in apps made in sketchware
ReplyDeletePlease send your your Whatsapp group link
ReplyDeleteHow can we set component widgets in these tab layouts ?
ReplyDeleteI also want to know.
DeleteHow can I use widgets and it's function in this ?
annabelle comes home full movie
ReplyDeleteالان على موقع مذركير احصل على جميع ما تحتاجه من منتجات مذركير للاطفال و جميع منتجات الام في فترة الحمل و كل ما تحتاجه و ذلك بجودة عالية و اقل الاسعار و مع خصومات رائعة مع كوبون خصم مذركير المميز و يوفر سرير مذركير ذو الجودة العالية و الذي لن تجده في اماكن اخرى
ReplyDeleteamin
DeleteCan u please provide another tutorial on how to use transformers with tablayout and viewpagers
ReplyDeleteError:
ReplyDeleteStop block doesn't exist in forever block.
Please help.
I want to send website link from firebase to app. And that link will be possible to be gone , when I will click.. how to do ?????
ReplyDeletehi
ReplyDeleteI am getting problem to make four side scroll. In sketchware vertical and horizontal are two different scroll only two sided
ReplyDeleteandroid.support.design cannot be resolved into type
ReplyDeleteI have same problem
DeleteI want to know how to create an appwidget with sketchware. Help me please
ReplyDeletethanks for amazing Write For Us Gaming
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHow to create keyboard app Book Marketing Services
ReplyDelete