I have a layout with tabs on top (added programmatically) and ViewFlipper under with 3 different views one of which contains a ListView. And I have 2 activities, one is the primary one that creates the tabs and one that dowloads some data and displays it in a new ListView. What I would like to do is start the second activity from the first one and display the data in the ListView that is inside ViewFlipper. Is it possible to do that?
What you are doing may be easier to achieve using fragments, or by putting the second activity into the ViewFlipper completely.
See the Android Developer site here for information on utilising fragments:
Related
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.
I want to divide my screen into four parts and add activities in each part. I am not interested in using fragment. Each activity should behave independent of other. Attached photo is showing what I exactly want to do.
In each child activity I want to add VideoView or WebView depending on the selection from menu item.
How can I do it. I didn't find any way to add activity to an activity.
Thanks :)
PS: Activity means Activity not fragment.
i strongly recommend 'using fragments' in your case as ActivityGroup is deprecated in API 13..
The only way you can do it by using fragments. Here is the simple example on how to add multiple fragments on single activity Link
Edit link
You can achieve this design by using four fragments, one for each child view inside a single activity.
The recommended way is to create a single XML layout for your activity, and create four fragments inside that layout.
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).
Basically I need some suggestions which is the best way to switch views in my situation. My Application has 5 different tabs. In every single tab I'm using activity manager to start as many activities that I need inside this tab. Now I have a little problem. In one of the tabs I need to create something like three different tabs. In second tabs I used 3 buttons, which switch the views via viewflipper. But now I have like 2 or 3 views inside every new tab (or button) which I need to switch. I did it with viewflipper but it's actually not what I want, because I want to use back button to switch between views.
Example:
MAIN TAB BAR : ONE TWO THREE FOUR FIVE
SECOND TAB BAR INSIDE TAB THREE / OR JUST THREE BUTTONS : TAB-A TAB-B TAB-C
IN TAB-A I have only one view.
IN TAB-B I have 2 views. View 1 is a listView and onItemClick switch view 2.
IN TAB-C I have same scenario like in TAB-B.
P.S. View 1 and View 2 directly can change to TAB-C.And I need to be able to send data between the views/activities.
Any suggestions how to do that? ViewFlipper or something else.
Better use activities inside the tab THREE and create three buttons which starts new activity.And you can use ViewFlipper inside these activities to change the views,or viewswticher.It depends on your needs.
You can override the onBackPressed in your activity to change the default behaviour of the back button
http://developer.android.com/reference/android/app/Activity.html#onBackPressed()
My current application has one Activity, the main one which extends ListActivity (listview of course).
The main Activity also holds most of the app functions.
I want to add an option for the user to select between 2 views: the current listView and a gridView.
I also want to reuse my code - most functions can be used for both Views.
Before I ask the actual question, note that my question is NOT how to add a gridView - it's already added and works great (when commenting out all Listview lines).
My question is - how should I do it?
2 different Views means I have to have 2 different Activities? one extends "ListActivity" and one extends "Activity"?
Should I create 4 classes (3 Activities and functions class in this case) where the main Activity will call one of the other Activities according to what the user selected?
Is there a way using the same main Activity for both Views? (right now I extend "ListActivity" to get "getListView()" which causes the gridView to force close as the Activity looks for a ListView with the ID "list").
Any other way?
Thank you!
You can use ListView without using a ListActivity. I would recommend this approach if the rest of your Activity's code will be similiar for both the List and Grid forms. Choose dynamically which one you show and tailor your adapter definitions to do both based on a switch or if statement where needed, rather than using different Activities.