我创建了一个TabHost
,里面有三个标签。如果我点击其中一个标签,
将打开Activity
Spinner
的{{1}}。如果我点击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);
答案 0 :(得分:2)
我刚刚更换了以下
setContentView(R.layout.employeepayslip);
到
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.employeepayslip, null);
this.setContentView(viewToLoad);