单击新Activity中的微调器时强制关闭。
问题描述:
我创建了一个TabHost
,其中包含三个选项卡。如果我点击我的标签之一, Activity
将Spinner
将被打开。如果我点击Spinner
,我的应用程序就会关闭。单击新Activity中的微调器时强制关闭。
我的活动:
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.employeepayslip);
到
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.employeepayslip, null);
this.setContentView(viewToLoad);
检查logcat的,看看它的崩溃。如果不明确,请在此处发布您的logcat和相关代码。 – 323go 2013-03-12 03:04:30
发布您的整个logcat。异常可能从其他地方一路传播开来。 – l46kok 2013-03-12 03:11:49
请给出更具体的日志。但我想你的活动还没有完全创建。 – MichaelP 2013-03-12 03:14:30