-3

How can I copy/clone a views automatically in android studio for example, I have one imageview and a textview. how can i clone them on runtime with different values alongside with existing objects like them.

I tried to make invisible views and and update them later. but I don't think its efficient way. plus it is also limited

I'm fetching data from JSON file. which will get a text description and an image link each time I update that file online. so I want to update that in android app too! but unfortunately I can't do with single textview and single imageview. so need to automatically make them whenever the data is updated online.

if there is any other way of cloning views. kindly tell me.

  • You should try rephrasing this if you want helpful answers. Add some code and maybe a more specific question. – Richard Dapice Aug 17 '19 at 06:58
  • you are probably looking for a recycler view https://developer.android.com/guide/topics/ui/layout/recyclerview – a_local_nobody Aug 17 '19 at 07:00
  • this might help [how-to-programmatically-add-views-to-views](https://stackoverflow.com/questions/2395769/how-to-programmatically-add-views-to-views) – AgentP Aug 17 '19 at 07:01

1 Answers1

2

First of all read this How to ask? , it's really hard to understand what you want us to help you with.

If i understand you correctly you want to display some kind of a list that updates when u update your JSON/Online database.

If that's the case I think the best way to go is RecyclerView it's basically an efficient way to create a dynamic list that can be updated at runtime

And here is a nice tutorial you can use

Dor
  • 657
  • 1
  • 5
  • 11