How to dynamically create layouts in android studio depending upon the user's input? - android-layout

So I'm trying to make an event organization app. The user needs to be able to manage multiple events at the same time. So, if he clicks on 'add event', I must be able to dynamically create a new layout folder for that respective event. How do I go about doing so?

It is not possible to "dynamically create a new layout folder for that respective event" but according to your requirement u can generate views dynamically according to your requirement or inflate a layout
(inflate layout)
1>How to inflate one view with a layout
generate view dynamically from code
2>Dynamically add textViews to a linearLayout
Hope this may help you

Related

Changing the Layout/Look of the app via Settings in Kotlin/Android

I'm trying to let the user change the layout of the Main Activity via settings. So for example someone can select the newest layout or the original older layout. What would be the best way to do this. Thanks.
All your layouts should have the same number of views, with the same IDs.
If you do so, then you can have a ConstraintLayout as the root layout, and create clones of the layout with the child items arranged in different ways. Then, based on the setting, you would apply the constrains from a specific layout to the master layout.
Check this for reference
Context context = this;
mConstraintSet2.clone(context, R.layout.state2); // get constraints from layout
setContentView(R.layout.state1);
mConstraintLayout = (ConstraintLayout) findViewById(R.id.activity_main);
mConstraintSet2.applyTo(mConstraintLayout)

Create and Load Custom Controls into FormView

i have a Form View in MFC. I try to include a dynamic Field, like C# User Control, where i can include other Controls, based on the clicked Item in the Lists.
I already found a User Control in Toolbox.
My question is:
Is it possible to create Form Views in Ressource View and add it to my Form View dynamically?
Can I use the Custom User Control to Replace it with my created FormView?
My FormView looks like this: Imagelink (Green Box should be filled with selected Control).
It is embedded in a TabView Item.
Or if this didnt work, i would bind different FormViews (Create same FormView with different green controls) to that TabView without the Ressource View at Runtime, is that possible?
I'm new to MFC and created my Prototype in C# .NET, so this is very hard to understand :)
I've found the solution. I'm now using different Groupboxes to arrange the Controls. I can show and hide them. Only the positioning should be a little bit hard.
https://www.codeproject.com/articles/32969/cstackablegroupbox-class-to-hide-group-of-controls

How to create an custom View for ListView?

How to create an custom ListView? I have Adapter, but I don't understand how to create an View like ListView of the Facebook, or App for SMS native from device... I'm needing background for TextView, this background, will have an arrow pointing left or right, I tried to create a View using canvas, but it is very difficult...
Every line in the listView of a layout which can be as complex as you want.Just you need an extra xml file for managing you custom layout (it should be contains widgets,fields,images etc as your design ) and the adapter would inflate this layout file for each row in its getView () method and assign the data to the individual views in the row .

Create Custom view in Android

I need to create a Custom view in android which will have dynamic text like price, address etc. and also an ImageView inside it as shown in the image below. I tried to find google some tutorial for custom view but didn't find something satisfactory to do all these things. I also need to use onClick event on this view. Please guys, some code would be of great help. I'm a novice to android. I read google tutorial to create custom view but couldn't implement this.
https://lh4.ggpht.com/HmwmRTx3g9ddkHbgvZXpZOB3Am-O9OQARQ2qpxJ16zTDZbG57CmvgxUC75sGFzC3cqrH
Thanks for attention.
This is called Custom Overlay for MapView.
You can check example and implement as per your requirement - Android MapView Balloons
You can use FrameLayouts. It is very simple to use. FrameLayout can add several views on top of each other. It creates a stack of the views. Just add whatever views you want to inside FrameLayout and use the property setVisibility() to control when to show which view.

adding buttons dynamically in android

I'm new to android development and needs help here.I want to create a layout where buttons are added dynamically.In this the no of buttons to be added are decided on the fly.(at run time) i.e depending upon the number return by server i want to add buttons.below is the layout i want to create.Please suggest me suitable solution.I was trying creating this layout with table layout.Thank You
http://i.stack.imgur.com/tbrEq.jpg
Read in your array of buttons and initialize your empty layout (i.e. setContentView). Then, create your buttons using the ImageButton constructor and call .addView(btn) from the layout where you want to insert the button. Don't forget to set any layout parameters you need.

Resources