I'm new to android. I wanna create something like this. two buttons to go "Next" and "Previous" content. middle content should be changed by pressing "Next" & "Previous" buttons. I think I can use fragments for this. but how to just change only middle area of a layout without changing whole layout.
thank you
Related
I've got multiple screens in my applications, which are nearly the same:
Basically there's a heading on the top and a view at the bottom including buttons. If I click on a button, the text of the heading should change. Then, when clicked on determined buttons, there should appear a second header, under the first one, in some cases a third. Each of them includes buttons. When clicking on a button of the second header, the third header should change, when clicking on the third header, only the content below the headers should change.
My target is also to nest (3) different templates, but to define each of them only for once (in xml). Is there a way to do this?
Don't know, if the image works, here's the link to dropbox.
Your main layout should be 3rd template layout.
You just have to hide the buttons or the button layout using attribute setvisibility="gone" in xml layout and in java when you click the button you can set visiblity to visible and you can also do set text to textview to change the header text to whatever you want on click of the buttons.
Hope this helps you
One solution is to declare different xml Views, which could be included by using the 'include' tag in other xml files.
I've followed this guide to make the sliding menu like the facebook app has.
When the Button is pressed, a new Layout shows from the left of the screen. But it pushes the orginal Layout with elements to the right of the screen. How can I make the Layout lay over the orginal Layout?
See the link for code samples. Thanks!
Let me rephrase my question
When I press the button, the text of the button, and the button itself will be pushed to one side, and aligned vertically. How can I just push the button "out of the screen"
To overlap layout/views above each other, you need to use FrameLayout. It sets the visibility of view (e.g. z-index in CSS) in the order as they are defined.
Sounds like you are adding the new layout to the parent layout which is why its pushing the original layout out of the way. You need to add the new layout to the original layout and it will lay in the original layout.
I have basic knowledge of layouts and so far in my applications I always had one static layout for each Activity. Now Im trying to create a single Activity with a basic framework (Title, some buttons) and a Layout I need to change after clicking a specified button.
Example:
I have a Title bar, a Linear Layout under it and 3 buttons under it. After clicking one of the 3 buttons I change the title text and the button appearance. But I also need to change my Linear Layout between Title bar and buttons. I didnt know how to do this exactly, so I made it Linear Layout in my main.xml, but after clicking one button, I actualy need it to be a Table Layout (or a List View), after clicking another button I need it to be a Relative layout. I hope you get the picture. In all cases I need to add some elements into it (table rows, some views etc.)
My question is, what is the best way to acomplish this? Thanks!
I want to make layout that expands dynamically, like some kind of menu.
It should look like this
http://imageshack.us/photo/my-images/845/dialog.jpg/
Step 1:
When I click on TextView it should inflate the new layout, remove transparent one, and move text to the left side.
Step 2:
When I click again on TextView (it's vertical custom TextView btw) it should go back to Step1
I want to put this layout into custom dialog and it should always be on my right side of the screen?
Any ideas how to solve this?
I can do this with two layouts and changing contentView of dialog on every click, but it seems like a very dirty solution. Is there some nice and fancy way to do this?
The simplest solution is probably just inflating all the Views, set their visibility accordingly, and move the TextView when the user clicks on it.
From the looks of it, it seems like you want to slide between a lot of views by clicking the TextView? If so, you might want to look into something called ViewPager, with a little customization you might be able to archive that.
Create two different layout's mentioned in images like 1) layoutone.xml 2)layouttwo.xml
Now crete on linearlayout in add that layout in your alertdialog. Also add layoutone in that linearlayout by inflating that layout. Now on click of that textview just removeallviews from that linearlayuout & inflate second layout & vice varsa.
just wondering if anyone else has a better suggestion that what I'm coming up with.
The issue is to do with a TabLayout, 5 Tabs all using a single Activity. Each Tab layout contains quite a few fields so the main parent on each tab is a ScrollView.
What I currently have is a 'Save' & 'Cancel' button sitting outside the scrollviews so theyre always visible and there for the user regardless which tab they're on. The problem is that since I'm using Tabs and always have these buttons visible when they are editing and the IME is displayed, they'res barely any of the form visible.
So I think the best thing for me to do is to probably show the buttons at the end of each scrollview. What I don't like about this is as I have 5 tabs, it will mean I have to declare 5 sets of the buttons, and of course define them and bind them in the Activity.. which seems rather messy and inefficient.
So if anyone has any better ideas I sure would love to hear them :-)
Thanks
Rgds,
Dave
Some of the options you got is
Try to put a title bar, and move the save and cancel buttons there (Small image buttons).
Save can be moved to the menu too (not recommended).
Auto Save functionality can also help, depends on how useful is it to you.
Try to use custom images for tabs, and make it take less space.
else, remove the save and cancel buttons, after the user makes any modifications, and presses back, prompt him to save the unsaved changes.
You could make it that when you're in tab X, the tab button for tab X now becomes X(save), so if they click again on the tab button in the same tab, it saves. That saves you five buttons, potentially...
Define programmatically the buttons inside a LinearLayout and add them to each ScrollView with addView. The code of the buttons should check in what tab are we at that moment, and act accordingly.
Then you'll have the same two buttons arranged in the same way in all your ScrollViews.
Or, if you dislike doing it programmatically, do a layout for the buttons and use View.inflate of that layout, and add them via addView to the ScrollView.