im trying to implement an android aplication when your activity, cointains 3 or more 'main windows' like in the image -> 'A'. 'B'.'C'. so how is posible make when you slide you touch screen change from A, to B, for example, i was thinkin in a horizontal view, and inside of each item use a relative layout, but im not sure, its my first time with this kind of problem, thanks.
Try using android ViewPager. Each ImageView would be inside a Fragment that would reside inside your Activity. Check out this example
Use Tabbed Activity template when you want to make this type of Activity. ViewPager, Adapter and tab layout will be automatically implemented for you. Just make small changes in your Adapter according to your needs and use one Fragment for one tab and you can create as many tabs as you want in an Activity.
If you want i will post an example of an Adapter as i just implemented an Activity with 3 tabs.
To get your basics strong on ViewPager, tab layout and Fragment sections adapter read out this link.
Related
I am new to Android programming. I started building an app using YouTube tutorials but I am a little bit confused and facing a problem. Should I use fragments or activity in my sliding tab? I am working on an Android project of employee attendance and payroll so I am thinking of using a slide tab (something like the screenshot below). The 1st tab may contain a form to add an employee and after adding it, will display information in list view and the other may contain salary. Should I try fragment or activity for my tabs?
A fragment is always located in an activity.
So you wil always need an Activity and then add the fragment to the activity.
if you say you want to slide?
you probably mean a viewpager, that can have n fragments. the viewpager needs a special viewpageradapter. where you define how many fragments you want. and at which index what fragment needs to be shown
I have a requirement in my application. my application has 6 fragments in a Navigation drawer each fragment represents single item in navigation drawer list.
But in one of the fragment i need to implement a form which will be spread across 5 views one at a time, can any one suggest me how to approach this in android.
Initially i thought of doing this using ViewPager , but i dont need horizontal swiping but need to go to next screen when clicked on a button.
Kindly advice me how to approach this.
Thanks & Regards.
Nagendra
You can create main fragment and sub-fragments. Inside the main fragment, show the sub-fragments by replacing them, store the data by creating an entity object here and pass it to the sub-fragments. Inside sub-fragments, pass the data to the main fragment entity using listeners.
I have been using this link to implement my two screen tabbed view,
http://developer.android.com/training/implementing-navigation/lateral.html
but my problem currently is that this demo only shows how to implement separate views on each tab such as a single TextView on each, whereas I wish to implement separate fragments on each tab that can interact with each other. For example, if a button is clicked on one fragment, I want it to change the text of a TextView on another fragment in the separate tab.
Currently I am using ONE fragment to implement both views and this is becoming complicated, because I can only do modifications to a certain view in the actual inflater of the view in the onCreateView method, rather than in the entire class.
So basically I want to separate them into 2 fragments and have them be able to interact with each other, but I am not sure how to configure them in the onCreateView method to work with the demo in the link I provided.
Thank you for any assistance you may have!
You can attach individual Fragment instances as pages of a ViewPager (instead of just simple views) using the FragmentPagerAdapter (docs link).
In my tablet application I want to create a fragment that displays information based on a list fragment click, the fragment has different tabs that I want to scroll between with a view pager. But the problem is that you can't do a fragment in a fragment so how can I achieve what I want to do or is it even possible to do what I want?
basically I have a persistant list fragment on he left, choosing an item shows some sort of view that I can scroll between tabs. I am trying to avoid creating a whole separate activity since I do a lot based on this list view click in this activity
If I understand you correctly then the only structure that comes to my mind is to use the ViewPager as the highest level and put the listadapter on the left side of each view, switching between the views by pressing on an item in the listView.
Just create one common xml base file and include the specifics for each view in the xml file for each view. This way you can have a hierachy in the xml file that makes development easier
i have develop one application in which tab layout in main file now i would like to set tablayout inside 2nd number tab,so what thing can i do? help me.
its "tab inside tab"
I think you want to give sub-options while clicking on 2nd tab button. For that, why dont you create layout with 2-3 options as you wants. And make it visible/invisible based on the 2nd button's click.
You can make visible/invisible any view by using setVisibility(View.VISIBLE) and setVisibility(View.GONE) method.
I suppose you can't embed a TabHost inside another TabHost. You can do what #Paresh said. Implement your own view switching. If you want an entire Activity embedded - take a look at ActivityGroup or the Fragments framework which you can use through the Compatibility Framework. Good luck.