This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

5
Good practices for dynamically adding/hiding/removing views in activities?
Post Body

First of all I would like to thank you guys for the great community here. I'm new at mobile development and this subreddit was really supportive so far.

Now little background, before I try to explain my conserns. I have a HTML5 game that I'm trying to turn it to an Application. So naturally the main component my workflow is the WebView, where I load the local web content(HTML/CSS/JS) and it's really great so far. I avoided using anything like React-Native, Cordova or Flutter because I really want understant what is happening under the hood...that's been said I did try something little more complex.

I would like to crosspromote in this app, in form of Views that will redirect to some urls:

  • A banner-type of View where I load image from res/drawable and put it on top of the WebView. Let's say it looks something like this:

        -------------------------------
       |           ImageView           |
       |-------------------------------|
       |                               |
       |                               |
       |                               |
       |                               |
       |            WebView            |
       |                               |
       |                               |
       |                               |
        -------------------------------

Basically I have RelativeLayout with WebView in it. At somepoint of Activity lifecycle I'm adding/hiding/removing the ImageView to the layout. Whenever I'm adding a ImageView to the layout I also manage the resizing of the WebView, beucase I don't want to block games content. That whole process sounds like a really simple deal, and it's definitely working. But I wouder if there is better approach here?

  • I going to use this post to ask another simular question. Right now I don't have some complex project architecture thats why I avoided using any type of design pattern. I have only 2 Activities - MainActivity handling WebView(and the ImageView banner explained) and FullScreenBannerActivity. So that 2nd Activity is kinda lame and I'm not sure is it done in the right direction.Why? So the idea here is to show FullScreenBannerActivity on every n-th app launch. I read about SharedPreference(btw is actually really useful) to store the app launch count and based on that I start the activity from the MainActivity. So what's in the FullScreenBannerAcitivty? Where there is no extra logic other that a Button that that reddirect to the URL, a static ImageView and TextView and a close Button. Again is there a better approach or something that should be aware of?

Looking back at the post it's kinda long and if you read that whole thing...Thanks. Hopefully I was able to explain the main problem here. Have a nice day!

Author
Account Strength
100%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
83,941
Link Karma
17,961
Comment Karma
65,751
Profile updated: 3 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago