I'm trying to make an app and I have made a blueprint for a specific activity, but I don't know how to implement it. The layout contains few buttons at the top of the activity, and each button features some information, which is displayed inside the view. The view which needs to be updated is present under the buttons. I don't want the activity to be changed, instead it should update the contents of the View, which is different for each category/button.
By doing some research I have realised that the "Tab Layout" can be used to achieve my requirements, but I don't want the tabs and I need some stylish buttons as a replacement.
I know I'm not the best at describing, so I have looked upon Dribble and found one design which is 100% similar to blueprint.
I want to achieve this using XML and Java using Android Studio! Every suggestion will be a great support foy my app.
Thanks a lot.
As far as I know, you could achieve that by using fragments (which is the same concept you would have used on TabLayout). I don't really know how much knowleadge you have on Android, but if you know what a Fragment is, it should be easy for you to recreate the idea.
You have 3 buttons for 3 different fragments, so you must design every fragment by separate and change it depending the button you click.
Related
After a lot of time spent I can't find the solution. I want a button or any clickable view should stay visible for all activities and it should be only for one specific app not like chat heads. I am basically making a library so that's why I can't use base activity.I have attached the image as well for a better explanation. How can I achieve this any suggestions? thankyou...
I
It sounds like you need a ViewOverlay. This is the API documentation.
ViewOverlay is usually tied to a single view, but if you wrap it in a fragment, you should be able to attach it to each view in your application. This should create the effect of an of an application scoped overlay.
There may be a more elegant way of doing this, but I am not aware of it.
EDIT: You can also wrap your layouts inside a frame layout(s) along with a seperate nested view (the view that you want to keep on top of the stack).
Frame layout creates a 'stack' of inner views. If you use this approach, you can programmatically ensure that there are exactly two views present and visible as children of your frame layout at all times. one will be the layout tied to your current activity. The other will be the view that you want to be overlayed.
I know that the term 'programmatically ensure' is vague. This is because there are many ways to make this happen. It is up to you to decide which way best suits your needs.
I'm building an app for educational purposes, with a lot of questions and challenges to the user to solve. But, it would be a HUGE amount of screens if I create a lot of questions and one xml file and activity for each one, as I want to have different kinds of questions, where the user should be able to write the code, select a block of code or select the correct answer about theory and stuff. Is there a way to use the same model of screen(xml file) for one specific kind of question? Like, using one model to all the screens and questions where the user should select the correct answer, and another model to another kind of question..
p.s: Yes, i'm kind newbie in Android
Thanks! :)
I would recommend using FragmentStatePagerAdapter
You only needs one layout and every time a fragment looses focus, it is destroyed automatically.
It is the same as adapters. You just create the visible views and 2 more. In this case you will have the visible question and one on the left and one on the right.
Let me know if you need any help.
You can define all kinds of questions, such as checkboxes, radioButtons, Edittexts and etc. in a xml file and, if necessary, visible or hide them.
Use Fragments to display questions in your activity.
In short, Fragments are mini-Activities with their own layouts, so each different type of question should have a corresponding Fragment. That should be exactly what you need.
For example, you can create a fragment_radiobox and a fragment_codesnippet in your project. In first one you will include a TextView for your question and a few checkboxes for an answer, and in the second one you'd have an EditText field to write some code. You can call any of those two fragments in your main activity depending on which question you want to display.
I am building a two column application for Android and I'm wondering how to do the navigation. The left column is the navigation bar. The right one is the content view. Both of them are LinearLayouts.
I have a different activity for all the options. How do I implement my menu into these? It is the same for all the activities (except the current one is highlighted), so copying the same code multiple times seems waste and makes it harder to change it later because I would have to change all the files.
I also have to change the title for every activity.
The typical answer would be Fragments. Here's a great tutorial on that topic.
However, depending on the triviality of your requirements, you could also consider using a horizontal LinearLayout containing your two original LinearLayouts.
in my opinion you should use fragments for your columns.
http://developer.android.com/guide/components/fragments.html
you Should use Fragment control for this. you can call content Fragments on right side (Content View) area with the click on leftSide(Content item/Index) .
I feel you should follow this link.
http://developer.android.com/training/multiscreen/screensizes.html
Am not sure but hopes u asked for the same.
Thanks..
Okay, So I just started Android development (I am average at VB.Net, so I understand basic code even if its not in VB). I've made a couple play around apps which used Text-To-Speech, Async Tasks and Reading/Writing files. However, I now wish to make a tabbed Android app.
I started the project in Eclipse Juno and filled in all the details. I then selected (For navigation) the Tabs/Swipe layout. I now have the default code for that layout type (Link to Tabs on developer.android.com - http://developer.android.com/design/building-blocks/tabs.html).
I understand mostly what the default code is doing. The only problem I am having, is determining the individual layout of my Tabs. I wish to have 2 Tabs, 1 in which the user selects an option, and the other, in which an image is shown depending on the selection in Tab 1.
So the question is: How do I create a .xml file in Layout to determine what is shown on the Fragment?
If you want to do this in XML the answer is simple, it can't be done just with XML, you must create a class that's implementing a ActionBar.TabListener.
Than you can override the onTabSelected method in which you can exchange the content.
A proper solution would be:
Use a LinearLayout as root container, and implement two Fragments for each of your Tabs (there you can design an individual XML-layout). Now you can add one fragment initially to the root-container and implement the exchange of the layouts inside the onTabSelected method and you are done.
I'm fairly new to Android programming and I've got this project I need to finish and I'm currently stuck.
I've got a standard listview in a Menu class with an array containing around 20 different elements. So what I want to do is load images in an imageview depending on which item in the listview I click, and since I'm a beginner the only idea I had was to make a new activity for each imageview which seems like a pretty bad way to do it since I'd need about 20-30 new activities..
To sum things up what I want is:
Code for making ONE activity that will display a different image depending on which item in the listview I click, probably pretty basic coding I want as simple solution as possible.
If possible I'm also looking for a solution that includes an SQLite database that stores the URL of an image and then display it in a single activity, also depending on which item I press in my current listview.
(I hope you understand my needs, and if you need I can also post my current code for the Menu class if it helps you help me) Or you can just show me a different way to make this work, I appreciate every answer! Thanks in advance!
NOTE
And please keep in mind, I'm a noob at Java and Android so keep it rather simple or at least explain what you do.
When you click on a list item, display the image in another view in the same layout, unless you want the image to take up the entire screen real estate. If you want it in the entire screen, go to a new Activity by sending the activity an Intent.
Activities are the "controller" of your application. They interact with the visible UI and the input from the user. You don't need a separate activity for each image, just an activity that's associated with a "place" in the UI (an ImageView) where you'll display the image.
I'd start by adding the images as resources under res/drawable before going on to databases.
You are going to have to do most of this yourself. There really isn't any substitute for taking the time to learn Java and Android. There are several tutorials and Android University classes under the Resources tab in the Developers Guide; I suggest you do all of them.