【发布时间】:2013-03-12 03:02:44
【问题描述】:
我创建了一个TabHost,其中包含三个选项卡。如果我点击我的一个标签,
将打开带有 Spinner 的 Activity。如果我点击 Spinner,我的应用程序将关闭。
我的活动:
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);
【问题讨论】:
-
检查您的 logcat 并查看它在哪里崩溃。如果不清楚,请在此处发布您的 logcat 和相关代码。
-
发布你的整个 logcat。异常可能从其他地方一直向上传播。
-
请提供更具体的日志。但我猜你的活动还没有完全创建。
-
感谢所有三个给我即时响应的人。现在,我得到了解决方案并发布为答案
标签: java android android-activity android-tabhost forceclose