Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
In this blog, I will show, how to create the dynamic views and get the data accordingly.
In this example, I am creating some UI elements on the screen at run time. Creating text view, RadioGroup, CheckBox and Spinner dynamically by dummy JSON data and creating the on click listener for button. After clicking on the button I will get the data from each created views and show it.
In this example, I have dynamically created four Types of Views
In this example, I have created above view by dummy JSON Data.
I am using option_name as a Heading
and variant_name as a sub data
option_type specifies the Type of the Views which is gotten from the JSON dummy data.
And I have used an ArrayList for storing the instance of the views.
and store the current view
After the views have created, We have to get the data which is selected in the views.
Then first we have to get the instance of current view
and then by below code you can get the data from spinner
Here I get the variant name of the spinner view but we can get anything which we want to get from views.
MainActivity.java
DummyData.java
activity_main.xml
spiner_row.xml
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Instead, it should be casted properly as: Spinner spinner = (Spinner) allViewInstance.get(noOfViews);
when another checkbox is added in the json dummy data.
This is casting exception and this has something to do with your code only.
Please do check the code more aptly.
Can you please share the stacktrace of the issue you are getting ?
Or if you want you can collect all the data first and then validate with a similar function.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
We've bought a Shopware Extension which is a hybrid App, which we can now offer in the Google Play Store and the IOS App Store. I'am still impressed how fast and how sharp the support team leads us through every process of the App-Store clarification. Very fast and useful response.
Markus Walter
Founder, Das Apartment Living
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.