1

I just wanted to ask if this is possible in android studio

enter image description here

As you can see I pointed out the blue area that I needed to change after I pressed the Send Profile button . Change I mean is that I can hide or something like that the fullname,address,phonenumber,emailaddress etc because I wanted to add some more forms to fill up.

Thank you if someone can direct me to a reference.

Ginxxx
  • 1,602
  • 2
  • 25
  • 54

3 Answers3

1

You can have a fragment place holder for the outlined blue area, and do fragment transitions as you want to go.

Each form can be represented by a separate xml layout file that you can place in this place holder.

Zain
  • 37,492
  • 7
  • 60
  • 84
  • hmmm can I create a fragment programmatically and by not adding new fragment by right clicking something like that? – Ginxxx Oct 27 '20 at 18:52
  • sure you can do that, you need a `FragmentTransaction` instance that you can call `.repace()` or `.add()`.. please have a look over [here](https://stackoverflow.com/questions/10122570/replace-a-fragment-programmatically) – Zain Oct 27 '20 at 18:54
  • but as far as I can understand fragment the whole page will be replaced right ? I just wanted the blue area to be replace by another forms to be fill up – Ginxxx Oct 27 '20 at 18:56
  • It's up to you if you want to replace the entire area of the activity or just a certain area, Doc quote: `You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities.` – Zain Oct 27 '20 at 18:59
1

Well... if you are using something like a Constraintlayout you can just reference the views and set their visibility to View.GONE So you would put that into the onClickListener of the Button (after validating perhaps) and then you could hide those views.

You can also use fragments but those might be hard for a beginner (which I assume you are) so instead for replacing those views you might be able to just use a mix of setting titles/hints of textfields to something different and hiding views (or showing new ones).

LinearLayout would also make this easy because views are just ontop of one another like in your case (only the blue area) so hiding/showing is straight forward.

Merthan Erdem
  • 5,598
  • 2
  • 22
  • 29
  • Yes I am new to android studio actually. But the fragment in not a bad idea tho cause i've got a bit of experience on it. Thank you – Ginxxx Oct 27 '20 at 18:51
  • No problem, appreciate the like. – Merthan Erdem Oct 27 '20 at 18:55
  • There's actually a problem on a fragment because I don't need to replace the whole page . I just need the specific space/area to be changed – Ginxxx Oct 27 '20 at 18:56
  • Well... it might be hard because getting Fragments working (especially clean) in this case really isn't something I'd recommend for beginners. Full Screen fragments yeah, but blue box only seems harder than it should be in your case perhaps – Merthan Erdem Oct 27 '20 at 19:00
1

Simplest way would be putting another LinearLayout there, and all those other elements into this new LinearLayout. Then you can just use

findViewById(R.id.yourNewLinearLayout).setVisibility(View.GONE);

to hide all those things.

Boba0514
  • 181
  • 1
  • 3
  • 15
  • so does my other forms will go up automatically if I set my first LinearLayout to invisible? – Ginxxx Oct 27 '20 at 18:53
  • If you set it to View.INVISIBLE, then no, but with View.GONE they will. If you want the 'Send profile' button to stay at the bottom, you could try putting an empty element before it with height=0dp. – Boba0514 Oct 27 '20 at 18:58