Friday, August 20, 2010

[android-developers] Re: How to change an activity in a tab

Hi,

I solved the problem. The answer is that first you have to create an
class extends from ActivityGroup and implements the OnTouchListener.
After you did that you can switch b/w differnet screens in one tab

The code look like that:

class TabActivityGroup extends ActivityGroup implements
OnTouchListener {

@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
//create a new intent and call the methode replaceContentView(String
id, Intent newIntent),
//for example Intent intent = new Intent().setClass(this,
myclass.class)
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

replaceContentView(String id, Intent newIntent)
return true;
}

public void replaceContentView(String id, Intent newIntent) {
View view = getLocalActivityManager().startActivity(id,
newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
this.setContentView(view);
}
}

the Tab class look like this

public class TabActivity extends TabActivity
{

Intent intent = new Intent().setClass(this, TabActivityGroup.class);
intent.putExtra("Content", 1);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

tabHost.addTab(tabHost.newTabSpec("Tab1")
.setIndicator("Tab1").setContent(intent));

}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate