qiuqingyu 2014-11-08 14:23 采纳率: 0%
浏览 7325

安卓开发中java.lang.RuntimeException: Unable to start activity ComponentInfo问题

package com.example.test;

import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

@SuppressWarnings("deprecation")
public class MainActivity extends ActivityGroup {

// Tab Activity Layout
private LocalActivityManager localActivityManager = null;
private LinearLayout mainTabContainer = null;
private Intent mainTabIntent = null;

// Tab banner title
private TextView mainTabTitleTextView = null;
// Tab ImageView
private ImageView appreciateImageView = null;
private ImageView discussImageView = null;
private ImageView identificationImageView = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    appreciateImageView = (ImageView) super
            .findViewById(R.id.appreciate_tab_btn);
    mainTabContainer = (LinearLayout) findViewById(R.id.main_tab_banner_title);
    appreciateImageView.setImageResource(R.drawable.appreciate_press);
    discussImageView.setImageResource(R.drawable.discuss_normal);
    identificationImageView
            .setImageResource(R.drawable.identification_normal);
    localActivityManager = getLocalActivityManager();
    mainTabTitleTextView = (TextView) findViewById(R.id.main_tab_banner_title);
    appreciateImageView = (ImageView) findViewById(R.id.appreciate_tab_btn);
    discussImageView = (ImageView) findViewById(R.id.discuss_tab_btn);
    identificationImageView = (ImageView) findViewById(R.id.identification_tab_btn);
    setContainerView("appreciate", AppreciateTabActivity.class);
    setContentView(R.layout.activity_main);

    initTab();

}

/**
 * 初始化Tab项
 */
private void initTab() {
    mainTabTitleTextView = (TextView) findViewById(R.id.main_tab_banner_title);
    appreciateImageView = (ImageView) findViewById(R.id.appreciate_tab_btn);
    discussImageView = (ImageView) findViewById(R.id.discuss_tab_btn);
    identificationImageView = (ImageView) findViewById(R.id.identification_tab_btn);




  appreciateImageView.setOnClickListener(new OnClickListener() {

  @Override public void onClick(View v) {

  appreciateImageView .setImageResource(R.drawable.appreciate_press);
  discussImageView.setImageResource(R.drawable.discuss_normal);
  identificationImageView
  .setImageResource(R.drawable.identification_normal);

  setContainerView("appreciate", AppreciateTabActivity.class);
  mainTabTitleTextView.setText("欣赏美花");

  } });




  discussImageView.setOnClickListener(new OnClickListener() {

  @Override public void onClick(View v) {

  appreciateImageView .setImageResource(R.drawable.appreciate_normal);
 discussImageView.setImageResource(R.drawable.discuss_press);
  identificationImageView
  .setImageResource(R.drawable.identification_normal);

  setContainerView("discuss", DiscussTabActivity.class);
  mainTabTitleTextView.setText("评花论花");

  } });




  identificationImageView.setOnClickListener(new OnClickListener() {

  @Override public void onClick(View v) {

  appreciateImageView .setImageResource(R.drawable.appreciate_normal);
  discussImageView.setImageResource(R.drawable.discuss_normal);
  identificationImageView
  .setImageResource(R.drawable.identification_press);
  setContainerView("identification", IdentificationTabActivity.class);
 mainTabTitleTextView.setText("亮眼识花");

  } });

}

public void setContainerView(String id, Class<?> activity) {
    mainTabContainer.removeAllViews();
    mainTabIntent = new Intent(this, activity);
    mainTabContainer.addView(localActivityManager.startActivity(id,
            mainTabIntent).getDecorView());
}

}
出现如下错误:CSDN移动问答

  • 写回答

1条回答

  • 关注

    跟我一样的 我也是这个状况 demo好的很

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题