代码很简单 就是跳转的代码 public void onClick(View v) { if (v.getId() == R.id.btn_groom) {
linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.getChildAt(0);
btn_groom.setBackgroundResource(R.drawable.weione);
btn_groom.setTextColor(this.getResources().getColor(R.color.black)); } else {
btn_groom.setBackgroundResource(R.drawable.wei);
btn_groom.setTextColor(this.getResources().getColor(R.color.white));
} if (v.getId() == R.id.btn_hot) { linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.addView(m_ActivityManager.
startActivity(
"1", //这里的的1不多说 大家都懂的
new Intent(MyTab.this, HotActivity.class)
).getDecorView());
btn_hot.setBackgroundResource(R.drawable.weione);
btn_hot.setTextColor(this.getResources().getColor(R.color.black)); } else {
btn_hot.setBackgroundResource(R.drawable.wei);
btn_hot.setTextColor(this.getResources().getColor(R.color.white));
} if (v.getId() == R.id.btn_date) {
linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.addView(m_ActivityManager.
startActivity("2",//2
new Intent(MyTab.this, MyDataActivity.class)
).getDecorView());
btn_date.setBackgroundResource(R.drawable.weione);
btn_date.setTextColor(this.getResources().getColor(R.color.black)); } else {
btn_date.setBackgroundResource(R.drawable.wei);
btn_date.setTextColor(this.getResources().getColor(R.color.white));
} if (v.getId() == R.id.btn_sorting) {
linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.addView(m_ActivityManager.
startActivity(
"3",//3
new Intent(MyTab.this, ListView_tab.class)
).getDecorView());
btn_sorting.setBackgroundResource(R.drawable.weione);
btn_sorting.setTextColor(this.getResources().getColor(R.color.black));
} else {
btn_sorting.setBackgroundResource(R.drawable.wei);
btn_sorting.setTextColor(this.getResources().getColor(R.color.white)); }
我现在的问题是 比如 if (v.getId() == R.id.btn_hot) 的跳转 现在是跳转到新的一页HotActivity.class 可是这个Hotactivity里面用一个griview显示数据 但是点击ITEM的时候触发不了事件,只能把startActivity( "1",new Intent(MyTab.this, HotActivity.class) ).getDecorView());这个1去掉 才能触发事件 这个怎么回事?
linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.getChildAt(0);
btn_groom.setBackgroundResource(R.drawable.weione);
btn_groom.setTextColor(this.getResources().getColor(R.color.black)); } else {
btn_groom.setBackgroundResource(R.drawable.wei);
btn_groom.setTextColor(this.getResources().getColor(R.color.white));
} if (v.getId() == R.id.btn_hot) { linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.addView(m_ActivityManager.
startActivity(
"1", //这里的的1不多说 大家都懂的
new Intent(MyTab.this, HotActivity.class)
).getDecorView());
btn_hot.setBackgroundResource(R.drawable.weione);
btn_hot.setTextColor(this.getResources().getColor(R.color.black)); } else {
btn_hot.setBackgroundResource(R.drawable.wei);
btn_hot.setTextColor(this.getResources().getColor(R.color.white));
} if (v.getId() == R.id.btn_date) {
linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.addView(m_ActivityManager.
startActivity("2",//2
new Intent(MyTab.this, MyDataActivity.class)
).getDecorView());
btn_date.setBackgroundResource(R.drawable.weione);
btn_date.setTextColor(this.getResources().getColor(R.color.black)); } else {
btn_date.setBackgroundResource(R.drawable.wei);
btn_date.setTextColor(this.getResources().getColor(R.color.white));
} if (v.getId() == R.id.btn_sorting) {
linearLayout.removeAllViews();
m_ActivityManager = getLocalActivityManager();
linearLayout.addView(m_ActivityManager.
startActivity(
"3",//3
new Intent(MyTab.this, ListView_tab.class)
).getDecorView());
btn_sorting.setBackgroundResource(R.drawable.weione);
btn_sorting.setTextColor(this.getResources().getColor(R.color.black));
} else {
btn_sorting.setBackgroundResource(R.drawable.wei);
btn_sorting.setTextColor(this.getResources().getColor(R.color.white)); }
我现在的问题是 比如 if (v.getId() == R.id.btn_hot) 的跳转 现在是跳转到新的一页HotActivity.class 可是这个Hotactivity里面用一个griview显示数据 但是点击ITEM的时候触发不了事件,只能把startActivity( "1",new Intent(MyTab.this, HotActivity.class) ).getDecorView());这个1去掉 才能触发事件 这个怎么回事?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货