求助此页面加载不出来,求大神解疑惑啊
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;public class MineActivity extends TabActivity implements OnClickListener{
public static String TAB_Love= "@string/love";
public static String TAB_Share= "@string/share";
public static String TAB_Follow = "@string/follow";
public static String TAB_Fans = "@string/fans";
public static TabHost mTabHost;
public Button Btn1, Btn2, Btn3,Btn4;
TextView Txt1, Txt2,Txt3,Txt4,Txt5;
private Animation left_in, left_out;
private Animation right_in, right_out;
Intent LoveItent, ShareIntent, FollowIntent,FansIntent;
int mCurTabId = R.id.btn1;
static final int COLOR1 = Color.parseColor("#000000");
static final int COLOR2 = Color.parseColor("#ffffff");
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);      setContentView(R.layout.mine);
     prepareAnim();
prepareIntent();
setupIntent();
prepareView();
}
private void prepareAnim() {
left_in = AnimationUtils.loadAnimation(this, R.anim.left_in);
left_out = AnimationUtils.loadAnimation(this, R.anim.left_out); right_in = AnimationUtils.loadAnimation(this, R.anim.right_in);
right_out = AnimationUtils.loadAnimation(this, R.anim.right_out);
}
// prepareIntent()喜欢Button,分享Button,粉丝Button,关注Button的触发页面的改变
private void prepareView() {  
Btn1 = (Button) findViewById(R.id.btn1);
Btn2 = (Button) findViewById(R.id.btn2);
Btn3 = (Button) findViewById(R.id.btn3);
Btn4 = (Button) findViewById(R.id.btn4);
findViewById(R.id.channel1).setOnClickListener(this);
findViewById(R.id.channel2).setOnClickListener(this);
findViewById(R.id.channel3).setOnClickListener(this);
findViewById(R.id.channel4).setOnClickListener(this);
findViewById(R.id.channel5).setOnClickListener(this);
Txt1 = (TextView) findViewById(R.id.txt1);
Txt2 = (TextView) findViewById(R.id.txt2);
Txt3 = (TextView) findViewById(R.id.txt3);
Txt4 = (TextView) findViewById(R.id.txt4);
Txt5 = (TextView) findViewById(R.id.txt5);
}

// prepareIntent()喜欢Button,分享Button,粉丝Button,关注Button的触发跳转页面事件
private void prepareIntent() {
LoveItent= new Intent(this, MineLoveActivity.class);
ShareIntent= new Intent(this, MineShareActivity.class);
FollowIntent= new Intent(this, MineFollowActivity.class);
FansIntent  = new Intent(this,MineFansActivity.class);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
Btn1.performClick();
return true;
}
return super.onKeyDown(keyCode, event);
} private void setupIntent() {
mTabHost = getTabHost();
mTabHost.addTab(buildTabSpec(TAB_Love, R.string.love, LoveItent));
mTabHost.addTab(buildTabSpec(TAB_Share,R.string.share,ShareIntent));
mTabHost.addTab(buildTabSpec(TAB_Follow, R.string.follow,FollowIntent));
mTabHost.addTab(buildTabSpec(TAB_Fans,R.string.fans, FansIntent));
}
private TabSpec buildTabSpec(String tAB_Fans2, int fans, int icon4n,
Intent fansIntent2) {
// TODO Auto-generated method stub
return null;
}
private TabHost.TabSpec buildTabSpec(String tag, int resLabel, final Intent content) {
return mTabHost
.newTabSpec(tag)
.setIndicator(getString(resLabel))
.setContent(content);
}
public static void setCurrentTabByTag(String tab) {
mTabHost.setCurrentTabByTag(tab);
}

//四个button的点击事件
@Override
public void onClick(View v) {
if (mCurTabId == v.getId()) {
return;
}
Btn1.setTextColor(COLOR1);
Btn2.setTextColor(COLOR1);
Btn3.setTextColor(COLOR1);
Btn4.setTextColor(COLOR1);
Txt1.setTextColor(COLOR1);
Txt2.setTextColor(COLOR1);
Txt3.setTextColor(COLOR1);
Txt4.setTextColor(COLOR1);
Txt5.setTextColor(COLOR1);
int checkedId = v.getId();
final boolean o;
if (mCurTabId < checkedId)
o = true;
else
o = false;
if (o)
mTabHost.getCurrentView().startAnimation(left_out);
else
mTabHost.getCurrentView().startAnimation(right_out);

//实现点击某个快,对应的button和人数由黑色变成白色
switch (checkedId) {
case R.id.channel1:
mTabHost.setCurrentTabByTag(TAB_Love);
Btn1.setTextColor(COLOR2);
Txt2.setTextColor(COLOR2);
break;
case R.id.channel2:
mTabHost.setCurrentTabByTag(TAB_Share);
Btn2.setTextColor(COLOR2);
Txt3.setTextColor(COLOR2);
break;
case R.id.channel3:
mTabHost.setCurrentTabByTag(TAB_Follow);
Btn3.setTextColor(COLOR2);
Txt4.setTextColor(COLOR2);
break;
case R.id.channel4:
mTabHost.setCurrentTabByTag(TAB_Fans);
Btn4.setTextColor(COLOR2);
Txt5.setTextColor(COLOR2);
break;
default:
break;
} if (o)
mTabHost.getCurrentView().startAnimation(left_in);
else
mTabHost.getCurrentView().startAnimation(right_in);
mCurTabId = checkedId;
}
  
}
android的页面四个按钮实现跳转android

解决方案 »

  1.   

    四个Button的按键响应时间没绑定。
    在prepareView()方法里加上:
            Btn1.setOnClickListener(this);
            Btn2.setOnClickListener(this);
            Btn3.setOnClickListener(this);
            Btn4.setOnClickListener(this);
    在onClick()方法里加上对应每个按钮的响应:startActivity(intent),传入对应的intent。
      

  2.   

    太感谢了,我解决了这个问题了,
    mTabHost.addTab(mTabHost.newTabSpec("love").setIndicator("",getResources ().getDrawable(R.id.Btn1)).setContent(new Intent(this, LoveActivity.class)));
    我这么写的话有问题吗/