Friday, April 18, 2014

TabHost in a TAB jumps two different activity


How?


As is shown in the results

<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Click the Network list to jump to a different activity while still in the same tab, '

Check this problem for a long time yet resolved. . . . .


Reply:
 
mHost = getTabHost ();
Intent localIntent1 = new Intent (this, MyTab.class);

mHost.addTab (mHost
. NewTabSpec ("home_tab")
. SetIndicator (getText (R.string.main_home),
getResources (). getDrawable (R.drawable.icon_1_n))
. SetContent (localIntent1));

Reply:
When the jump page, TAB's ID has not changed on OK

Reply:
reference to the second floor piaolankeke reply:
Java code

mHost = getTabHost ();
Intent localIntent1 = new Intent (this, MyTab.class);

mHost.addTab (mHost
. NewTabSpec ("home_tab")
. SetIndicator (getText (R.string.main_home),
......


Each click will add a TAB? ?

Seemingly not, right?
Reply:
reference to the third floor fyan1900 reply: When
jump page, TAB's ID has not changed on OK


Can buddies say more points?
Reply:
How can I say this.
Yeah personal way.
Is to develop an ID for each Tab:
if (id = 1) {
Implementation of a tab
} Else if (id = 2) {
Perform a second TAB
} Else if (x = 3) {
Implementation of the third ta ...
Here is the activity you want to perform, you can re-transmission of ID = 3 to this page, so he still performs the third tab, this choice is the third TAB
}

Speaking feel really very hard to say.
Reply:
reference to the 6th floor fyan1900 reply:
me how to say this.
Yeah personal way.
Is to develop an ID for each Tab:
if (id = 1) {
Implementation of a tab
} Else if (id = 2) {
Perform a second TAB
} Else if (x = 3) {
Implementation of the third ta ...
Here is the activity you want to perform, you can re-transmission of ID = 3 to this page, so he still performs the third tab, this choice is the third TAB
}

Speaking sense ......



I do not want to switch TAb the same TAB button click after the jump to another activity ah

The tab also unchanged


Reply:
Does no one would it? ? ? ? ? ? Collapse
Reply:
Use ViewFlipper control, which can add more than one layout, and control the jump, check it Baidu Google
Reply:
ViewFlipper vfFling = (ViewFlipper) this.findViewById (R.id.details);
View contentlist_v = View.inflate (this, R.layout.auto_cert, null);
vfFling.addView (contentlist_v, 0);
This will add the ViewFlipper in the first interface, and so on more than one

vfFling.showNext (); display the next screen
vfFling.showPrevious (); displayed on a screen
Reply:
reference to the 9th floor liurui1129 reply:
use ViewFlipper control, which can add more than one layout, and control the jumps, Baidu Google check it


Buddy ah, the project has been decided to use tabhost the

I think again, thank you for providing a solution
Reply:
Hey, I did not let you remove tabHost ah, each corresponding to an activity tabHost it, use ViewFlipper this control in every activity of the interface, the interface of each tabHost all sub-pages are placed ViewFlipper, use ViewFlipper to control the switch interface, understand?
Reply:
This method has been used in our projects, good
Reply:
Please say more points
Reply:

<-! Buffet forensics main interface ->
xmlns: android = "http://schemas.android.com/apk/res/android"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">



This is every tabHost corresponding interface layout, which is only a ViewFlipper control, use this control to add multiple interface layout you want to display and control the jumps, under your Google, many examples
Reply:
cited 15 floor liurui1129 reply:

<-! Buffet forensics main interface ->
xmlns: android = "http://schemas.android.com/apk/res/android"
android: layout_width = "fill_parent"
android: layout_height = "fi ......


Ah, looks good, Thanks buddy. But I still want me to ask this question to get rid

You said I will try this method when the project drops late optimized code. Oh


Reply:
I now want to know how to jump two activity?

Could there is no way to achieve it? ?

Tangled ing

No solution found online
Reply:
There are examples of API Demo. I've seen it before.
Reply:
Hey, still have to go on a foreign site search ah

Use Android ActivityGroup within TabHost to show different Activity

http://united-coders .com / nico-heid / use-android-activitygroup-within-tabhost-to-show-different-activity


Android ViewFlipper within TabHost for Tabs with different Views ... and better memory footprint
http :/ / united-coders.com/nico-heid/android-viewflipper-within-tabhost-for-tabs-with-different-views-and-better-memory

Reply:
Seemingly better performance
with ViewFlipper
Thank liurui1129, thank you

Posts placed first, I go home first fiddle at the code, paste
knot tomorrow

Reply:
ViewFlipper can achieve the function you say Yeah, no need to have all activity
Reply:
cited 21 floor liurui1129 reply:
ViewFlipper can achieve the function you say Yeah, no need to have all activity
< br />
Blessings are using it, I feel good ha. . Haha

Thanks

Reply:
In fact, do not be confused by appearances, like the figure of my cool interface, the bottom may be used RiadioGroup written. And click "network list" when the switch is really a tab, but because the bottom is to write your own, you do not switch into it with your decision.
Reply:
Top ls
Reply:
The second interface is simple and direct ah is also set to the same as the first interface to OK a look that is LISTview
Reply:
Try Try
Reply:
Oh, the questions raised by the landlord, in the 19th floor of the second link has been given a solution is to use tabHost plus viewFlipper achieved considerable eary, plus quite a day Replies
Reply:
viewFlipper not meet the conditions of Acticity Tab need to pass parameters, right?
For example, I have an Activity, the parameters need to be passed before the switch, so how should achieve?
Moreover, with viewFlipper then all must be defined in an XML Layout in? Not very convenient
Reply:
cited 28 floor andy_123 reply:
viewFlipper Tab can not meet the needs of the situation to pass parameters Acticity right?
For example, I have an Activity, the parameters need to be passed before the switch, so how should achieve?
Moreover, with viewFlipper then all must be defined in an XML Layout in? Not very convenient


Dude has a better solution? ?
I am currently employed on this project. You can also feel it.

        


Reply:
I need this result! ! !
Reply:
Seeking the same solution
Reply:
I have recently encountered such a problem, read your post, benefited ~
Reply:
I have encountered this problem, going to try ViewFlipper
Reply:
ActivityGroup resolved
Reply:
Encountered the same problem, but the problem has been resolved, the idea is very simple

Intent intent1 = new Intent (this, HotnewproductActivity.class);
Intent intent2 = new Intent (this, HotnewproductActivity.class);
Intent intent3 = new Intent (this, HotnewproductActivity.class);
Intent intent4 = new Intent (this, HotnewproductActivity.class);

intent1.putExtra ("Type", "hotnewproduct");
tabHost.addTab (tabHost.newTabSpec ("tab1").
. setIndicator ("new list") setContent (intent1));

intent2.putExtra ("Type", "hotproduct");
tabHost.addTab (tabHost.newTabSpec ("tab2").
. setIndicator ("chart") setContent (intent2));

intent3.putExtra ("Type", "hotbrand");
tabHost.addTab (tabHost.newTabSpec ("tab3").
. setIndicator ("brands list") setContent (intent3));

intent4.putExtra ("Type", "topcomment");
tabHost.addTab (tabHost.newTabSpec ("tab4").
. setIndicator ("Review list") setContent (intent4));
Reply:
Before writing a program to use TabActivity, which has a multi-level list to the next tab, in fact, like "Set 'switch pages, as if it touches directly start an activity, you will find that this activity will become a full-screen, and before the TabActivity half dime wood, so when I feel it very troublesome problem.
Later, I went TabActivity found inside, TabActivity is actually inherited from ActivityGroup, then think of it before seeing an article, with ActivityGroup to implement custom TabActivity function here should in fact very simple, nothing is TabActivity add a subActivity, But here I find it troublesome, and TabActivity not simply something to do, so he used a nested ActivityGroup way to achieve, in fact, put a TabActivity replaced by a sub-page ActivityGroup, and then put on the ActivityGroup following several subactivity. Of course, ActivityGroup inherited from Activity, so you have to take it as activity to mainfest registered it.
I'm comin 'car to go home, time is tight, ugly point format, forgive me. Here is the key code:

TabActivity usage I will not say, a search a lot, the key is switched ActivityGroup within the activity, one inherited from ActivityGroup of class MyActivityGroup, MyActivityGroup in TabActivity inside and general activity using the same two sub activitySubAActivity.class and SubBActivity. class, the first to start a subactivity MyActivityGroup start when we start SubAActivity.class, MyActivityGroup the onCreate achieved,
protected void onCreate (Bundle savedInstanceState) {
/ / TODO Auto-generated method stub
super.onCreate (savedInstanceState);
setContentView (R.layout.myactivitygroup) ;/ / In fact, this is only an id for the layout inside the LinearLayout
myactivitygroup _viewcontainer = (LinearLayout) findViewById (R.id.myactivitygroup _view) ;/ /
container.removeAllViews ();
Intent intent = new Intent (MyActivityGroup this, SubAActivity.class.);
intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
. Window subActivity = getLocalActivityManager () startActivity ("SubAActivity", intent);
View view = subActivity.getDecorView ();
container.addView (view); / / The following code is to ensure subactivity display properly, it must be written on the back row, otherwise, view object has not been generated, then. . . You know, addView should also be realized by
InFlateLinearLayout.LayoutParams params = (LayoutParams) view.getLayoutParams ();
params.width = LayoutParams.FILL_PARENT;
params.height = LayoutParams.FILL_PARENT;
view.setLayoutParams (params);
}
Copy the code
Here is the jump from SubAActivity to SubBActivity, (returned from SubBActivity SubAActivity the same method, but the location is not the same place) Suppose I realized
OnClickListener inside of a listviewlist.setOnGroupClickListener (new OnGroupClickListener () {

@ Override
public boolean onGroupClick (ExpandableListView parent, View v,
int groupPosition, long id) {
LinearLayout container = (LinearLayout) ((ActivityGroup) getParent ()). GetWindow (). FindViewById (R.id.myactivitygroup _view) ;/ / note here, or get group's view
container.removeAllViews ();
Intent intent = new Intent (SubAActivity.this, SubBActivity.class);
intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
Window subActivity = ((ActivityGroup) ProvinceParkActivity.this.getParent ()) getLocalActivityManager () startActivity ("SubBActivity", intent);..
View view = subActivity.getDecorView ();
container.addView (view);
LinearLayout.LayoutParams params = (LayoutParams) view.getLayoutParams ();
params.width = LayoutParams.FILL_PARENT;
params.height = LayoutParams.FILL_PARENT;
view.setLayoutParams (params);
return true;
}
});
Copy the code
Look closely you will find that these two codes are the same as the realization of the idea, another way to achieve the activitygroup can probably also some speculation.
Do not call in subactivity finish, otherwise the tree will hang the entire activity, subactivity you carefully observe and tab to switch between, you will find very interesting.

Just wrote a half, post even refresh, really tragic - #
Well, I'm going to depart you, I wish you all a Happy New Year! ~

Supplemental content (2011-1-30 16:43):
How can not be edited -
I want the next container.addView (view); / / The following code is to ensure subactivity display properly, it must be written on the back row, otherwise, xxxxxxxxx
This statement is not correct, xxxxxx part.

No comments:

Post a Comment