Java 单击新活动中的微调器时强制关闭。
我创建了一个包含三个选项卡的Java 单击新活动中的微调器时强制关闭。,java,android,android-activity,android-tabhost,forceclose,Java,Android,Android Activity,Android Tabhost,Forceclose,我创建了一个包含三个选项卡的TabHost。如果我单击其中一个选项卡, 将打开带有微调器的活动。如果单击该微调器,我的应用程序强制关闭 我的活动: setContentView(R.layout.employeepayslip); btn=(Button)findViewById(R.id.button1); //Submit Bundle extras = getIntent().getExtras(); idviewslip = extras.getString(
TabHost
。如果我单击其中一个选项卡,
将打开带有微调器的活动
。如果单击该微调器
,我的应用程序强制关闭
我的活动:
setContentView(R.layout.employeepayslip);
btn=(Button)findViewById(R.id.button1); //Submit
Bundle extras = getIntent().getExtras();
idviewslip = extras.getString("idviewslip");
empid=(TextView)findViewById(R.id.empid1);
empname=(TextView)findViewById(R.id.empname1);
empdesignation=(TextView)findViewById(R.id.empdesignation);
sp1=(Spinner) findViewById(R.id.spinner1);
ArrayAdapter<String>Adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,months);
sp1.setAdapter(Adapter);
sp1.setOnItemSelectedListener(this);
sp2=(Spinner) findViewById(R.id.spinner2);
ArrayAdapter<String>Adapter1=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,years);
sp2.setAdapter(Adapter1);
sp2.setOnItemSelectedListener(this);
setContentView(R.layout.employeepaysslip);
btn=(按钮)findViewById(R.id.button1)//提交
Bundle extras=getIntent().getExtras();
idviewslip=extras.getString(“idviewslip”);
empid=(TextView)findViewById(R.id.empid1);
empname=(TextView)findViewById(R.id.empname1);
empdesignation=(TextView)findViewById(R.id.empdesignation);
sp1=(微调器)findViewById(R.id.spinner1);
ArrayAdapterAdapter=新的ArrayAdapter(这是android.R.layout.simple\u微调器\u项,月份);
设置适配器(适配器);
sp1.setOnItemSelectedListener(此);
sp2=(喷丝器)findViewById(R.id.spinner2);
ArrayAdapterAdapter1=新的ArrayAdapter(这个,android.R.layout.simple\u微调器\u项目,年);
sp2.设置适配器(适配器1);
sp2.setOnItemSelectedListener(此);
我刚刚替换了以下内容
setContentView(R.layout.employeepayslip);
到
检查你的logcat,看看它在哪里崩溃。如果不清楚,请在此处发布日志和相关代码。发布整个日志。异常可能从其他地方一直传播到上。请提供更具体的日志。但是我想你的活动还没有完全创造出来。谢谢所有三个人给我的即时回复。现在,我得到了解决方案并作为答案发布
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.employeepayslip, null);
this.setContentView(viewToLoad);