public class MainActivity extends TabActivity { |
TabHost tabHost; |
TabHost.TabSpec tabSpec; |
RadioGroup radioGroup; |
RelativeLayout bottom_layout; |
ImageView img; |
int startLeft; |
@Override |
public void onCreate(Bundle savedInstanceState) { |
super .onCreate(savedInstanceState); |
setContentView(R.layout.main); |
|
bottom_layout = (RelativeLayout) findViewById(R.id.layout_bottom); |
|
tabHost = getTabHost(); |
tabHost.addTab(tabHost.newTabSpec( "news" ).setIndicator( "News" ).setContent( new Intent( this , TabNewsActivity. class ))); |
tabHost.addTab(tabHost.newTabSpec( "topic" ).setIndicator( "Topic" ).setContent( new Intent( this , TabTopicActivity. class ))); |
tabHost.addTab(tabHost.newTabSpec( "picture" ).setIndicator( "Picture" ).setContent( new Intent( this , TabPicActivity. class ))); |
tabHost.addTab(tabHost.newTabSpec( "follow" ).setIndicator( "Follow" ).setContent( new Intent( this , TabFollowActivity. class ))); |
tabHost.addTab(tabHost.newTabSpec( "vote" ).setIndicator( "Vote" ).setContent( new Intent( this , TabVoteActivity. class ))); |
|
radioGroup = (RadioGroup) findViewById(R.id.radiogroup); |
radioGroup.setOnCheckedChangeListener(checkedChangeListener); |
|
img = new ImageView( this ); |
img.setImageResource(R.drawable.tab_front_bg); |
bottom_layout.addView(img); |
} |
|
private OnCheckedChangeListener checkedChangeListener = new OnCheckedChangeListener() { |
public void onCheckedChanged(RadioGroup group, int checkedId) { |
switch (checkedId) { |
case R.id.radio_news: |
tabHost.setCurrentTabByTag( "news" ); |
// moveFrontBg(img, startLeft, 0, 0, 0); |
MoveBg.moveFrontBg(img, startLeft, 0 , 0 , 0 ); |
startLeft = 0 ; |
break ; |
case R.id.radio_topic: |
tabHost.setCurrentTabByTag( "topic" ); |
MoveBg.moveFrontBg(img, startLeft, img.getWidth(), 0 , 0 ); |
startLeft = img.getWidth(); |
break ; |
case R.id.radio_pic: |
tabHost.setCurrentTabByTag( "picture" ); |
MoveBg.moveFrontBg(img, startLeft, img.getWidth() * 2 , 0 , 0 ); |
startLeft = img.getWidth() * 2 ; |
break ; |
case R.id.radio_follow: |
tabHost.setCurrentTabByTag( "follow" ); |
MoveBg.moveFrontBg(img, startLeft, img.getWidth() * 3 , 0 , 0 ); |
startLeft = img.getWidth() * 3 ; |
break ; |
case R.id.radio_vote: |
tabHost.setCurrentTabByTag( "vote" ); |
MoveBg.moveFrontBg(img, startLeft, img.getWidth() * 4 , 0 , 0 ); |
startLeft = img.getWidth() * 4 ; |
break ; |
default : |
break ; |
} |
} |
}; |
} |
初级程序员
by: 云代码会员 发表于:2016-04-17 10:18:31 顶(0) | 踩(0) 回复
拉拉裤图,,。。。。。。。。。
回复评论