基本信息
源码名称:android 仿网易客户端 底部切换tab签
源码大小:0.60M
文件格式:.rar
开发语言:Java
更新时间:2018-06-15
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 6 元×
微信扫码支付:6 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.widget.ImageView; import android.widget.RadioGroup; import android.widget.RadioGroup.OnCheckedChangeListener; import android.widget.RelativeLayout; import android.widget.TabHost; import com.and.netease.utils.MoveBg; @SuppressWarnings("deprecation") 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() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.radio_news: tabHost.setCurrentTabByTag("news"); 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; } } }; }