1- from java import cast , jclass
1+ from java import jclass
2+
23
34def create_widgets (context ):
45 # Java Classes
5- RelativeLayout = jclass ('android.widget.RelativeLayout' )
6- FrameLayout = jclass ('android.widget.FrameLayout' )
7- GridLayout = jclass ('android.widget.GridLayout' )
8- LinearLayout = jclass ('android.widget.LinearLayout' )
9- Button = jclass ('android.widget.Button' )
10- TextView = jclass ('android.widget.TextView' )
11- EditText = jclass ('android.widget.EditText' )
12- CheckBox = jclass ('android.widget.CheckBox' )
13- RadioButton = jclass ('android.widget.RadioButton' )
14- ImageView = jclass ('android.widget.ImageView' )
15- ProgressBar = jclass ('android.widget.ProgressBar' )
16- Switch = jclass ('android.widget.Switch' )
17- ToggleButton = jclass ('android.widget.ToggleButton' )
18- SeekBar = jclass ('android.widget.SeekBar' )
19- CardView = jclass ('androidx.cardview.widget.CardView' )
20- ViewPager = jclass ('androidx.viewpager.widget.ViewPager' )
21- DatePicker = jclass ('android.widget.DatePicker' )
22- TimePicker = jclass ('android.widget.TimePicker' )
23- Spinner = jclass ('android.widget.Spinner' )
24- AutoCompleteTextView = jclass ('android.widget.AutoCompleteTextView' )
25- RatingBar = jclass ('android.widget.RatingBar' )
6+ RelativeLayout = jclass ("android.widget.RelativeLayout" )
7+ FrameLayout = jclass ("android.widget.FrameLayout" )
8+ GridLayout = jclass ("android.widget.GridLayout" )
9+ LinearLayout = jclass ("android.widget.LinearLayout" )
10+ Button = jclass ("android.widget.Button" )
11+ TextView = jclass ("android.widget.TextView" )
12+ EditText = jclass ("android.widget.EditText" )
13+ CheckBox = jclass ("android.widget.CheckBox" )
14+ RadioButton = jclass ("android.widget.RadioButton" )
15+ ImageView = jclass ("android.widget.ImageView" )
16+ ProgressBar = jclass ("android.widget.ProgressBar" )
17+ Switch = jclass ("android.widget.Switch" )
18+ ToggleButton = jclass ("android.widget.ToggleButton" )
19+ SeekBar = jclass ("android.widget.SeekBar" )
20+ CardView = jclass ("androidx.cardview.widget.CardView" )
21+ ViewPager = jclass ("androidx.viewpager.widget.ViewPager" )
22+ DatePicker = jclass ("android.widget.DatePicker" )
23+ TimePicker = jclass ("android.widget.TimePicker" )
24+ Spinner = jclass ("android.widget.Spinner" )
25+ AutoCompleteTextView = jclass ("android.widget.AutoCompleteTextView" )
26+ RatingBar = jclass ("android.widget.RatingBar" )
27+ AbsoluteLayout = jclass ("android.widget.AbsoluteLayout" )
28+ ScrollView = jclass ("android.widget.ScrollView" )
29+ HorizontalScrollView = jclass ("android.widget.HorizontalScrollView" )
30+ TableLayout = jclass ("android.widget.TableLayout" )
31+ TableRow = jclass ("android.widget.TableRow" )
32+ ViewFlipper = jclass ("android.widget.ViewFlipper" )
33+ ViewSwitcher = jclass ("android.widget.ViewSwitcher" )
34+ WebView = jclass ("android.webkit.WebView" )
35+ RecyclerView = jclass ("androidx.recyclerview.widget.RecyclerView" )
36+ DrawerLayout = jclass ("androidx.drawerlayout.widget.DrawerLayout" )
37+ CoordinatorLayout = jclass ("androidx.coordinatorlayout.widget.CoordinatorLayout" )
38+ BottomNavigationView = jclass (
39+ "com.google.android.material.bottomnavigation.BottomNavigationView"
40+ )
41+ Chip = jclass ("com.google.android.material.chip.Chip" )
42+ FloatingActionButton = jclass (
43+ "com.google.android.material.floatingactionbutton.FloatingActionButton"
44+ )
45+ Snackbar = jclass ("com.google.android.material.snackbar.Snackbar" )
46+ NavigationView = jclass ("com.google.android.material.navigation.NavigationView" )
47+ ConstraintLayout = jclass ("androidx.constraintlayout.widget.ConstraintLayout" )
48+ TextInputLayout = jclass ("com.google.android.material.textfield.TextInputLayout" )
49+ MaterialCardView = jclass ("com.google.android.material.card.MaterialCardView" )
50+ BottomSheetDialogFragment = jclass (
51+ "com.google.android.material.bottomsheet.BottomSheetDialogFragment"
52+ )
2653
2754 # Create LinearLayout
2855 layout = LinearLayout (context )
29- layout_params = LinearLayout .LayoutParams (LinearLayout .LayoutParams .MATCH_PARENT ,
30- LinearLayout .LayoutParams .WRAP_CONTENT )
56+ layout_params = LinearLayout .LayoutParams (
57+ LinearLayout .LayoutParams .MATCH_PARENT , LinearLayout .LayoutParams .WRAP_CONTENT
58+ )
3159 layout .setLayoutParams (layout_params )
3260 layout .setOrientation (LinearLayout .VERTICAL )
3361
3462 # Create Button
3563 button = Button (context )
36- button .setText (' Button created in Python' )
64+ button .setText (" Button created in Python" )
3765 layout .addView (button )
3866
3967 # Create TextView
4068 text_view = TextView (context )
41- text_view .setText (' TextView created in Python' )
69+ text_view .setText (" TextView created in Python" )
4270 layout .addView (text_view )
4371
4472 # Create EditText
4573 edit_text = EditText (context )
46- edit_text .setHint (' EditText created in Python' )
74+ edit_text .setHint (" EditText created in Python" )
4775 layout .addView (edit_text )
4876
4977 # Create CheckBox
5078 check_box = CheckBox (context )
51- check_box .setText (' CheckBox created in Python' )
79+ check_box .setText (" CheckBox created in Python" )
5280 layout .addView (check_box )
5381
5482 # Create RadioButton
5583 radio_button = RadioButton (context )
56- radio_button .setText (' RadioButton created in Python' )
84+ radio_button .setText (" RadioButton created in Python" )
5785 layout .addView (radio_button )
5886
59- # Create ImageView
87+ # Create ImageView (X)
6088 image_view = ImageView (context )
6189 layout .addView (image_view )
6290
@@ -66,44 +94,44 @@ def create_widgets(context):
6694
6795 # Create Switch
6896 switch = Switch (context )
69- switch .setText (' Switch created in Python' )
97+ switch .setText (" Switch created in Python" )
7098 layout .addView (switch )
7199
72100 # Create ToggleButton
73101 toggle_button = ToggleButton (context )
74- toggle_button .setTextOn ('On' )
75- toggle_button .setTextOff (' Off' )
102+ toggle_button .setTextOn ("On" )
103+ toggle_button .setTextOff (" Off" )
76104 layout .addView (toggle_button )
77105
78- # Create SeekBar
106+ # Create SeekBar (X)
79107 seek_bar = SeekBar (context )
80108 layout .addView (seek_bar )
81109
82- # Create CardView
110+ # Create CardView (X)
83111 card_view = CardView (context )
84112 layout .addView (card_view )
85113
86- # Create ViewPager
114+ # Create ViewPager (X)
87115 view_pager = ViewPager (context )
88116 layout .addView (view_pager )
89117
90- # Create DatePicker
118+ # Create DatePicker (X)
91119 date_picker = DatePicker (context )
92120 layout .addView (date_picker )
93121
94- # Create TimePicker
122+ # Create TimePicker (X)
95123 time_picker = TimePicker (context )
96124 layout .addView (time_picker )
97125
98- # Create Spinner
126+ # Create Spinner (X)
99127 spinner = Spinner (context )
100128 layout .addView (spinner )
101129
102- # Create AutoCompleteTextView
130+ # Create AutoCompleteTextView (X)
103131 auto_complete_text_view = AutoCompleteTextView (context )
104132 layout .addView (auto_complete_text_view )
105133
106- # Create RatingBar
134+ # Create RatingBar (X)
107135 rating_bar = RatingBar (context )
108136 layout .addView (rating_bar )
109137
0 commit comments