我正在尝试从现有弹出窗口创建另一个弹出窗口。我也不希望第一个弹出窗口消失。我的意图是让用户将值插入表单(第二个弹出窗口)并返回第一个。我收到一个错误:不幸的是它已经停止了。这是我尝试过的代码。
主屏幕:
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
position = report_spinner.getSelectedItemPosition();
switch (position){
case 0:
break;
case 1:
break;
case 2:
startActivity(new Intent (NewCase.this,ArrestPop.class));
break;
case 3:
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
First Popup:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.arrest_popup);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
getWindow().setLayout((int) (width * .4), (int) (height * .6));
agencyInfo_Button = (Button) findViewById(R.id.bAgencyInfo);
arresteeInfo_Button = (Button) findViewById(R.id.bArrestee);
arrestInfo_Button = (Button) findViewById(R.id.bArrestInfo);
vehInfo_Button = (Button) findViewById(R.id.bVehicle);
bondInfo_Button = (Button) findViewById(R.id.bBond);
drugsInfo_Button = (Button) findViewById(R.id.bDrugs);
complainant_Button = (Button) findViewById(R.id.bVictim);
narrative_Button = (Button) findViewById(R.id.bNarrative);
status_Button = (Button) findViewById(R.id.bStatus);
saveArrest_Button = (Button) findViewById(R.id.bSaveArrest);
cancelArrest_Button = (Button) findViewById(R.id.bCancelArrest);
agencyInfo_Button.setOnClickListener(this);
arresteeInfo_Button.setOnClickListener(this);
arrestInfo_Button.setOnClickListener(this);
vehInfo_Button.setOnClickListener(this);
bondInfo_Button.setOnClickListener(this);
drugsInfo_Button.setOnClickListener(this);
complainant_Button.setOnClickListener(this);
narrative_Button.setOnClickListener(this);
status_Button.setOnClickListener(this);
saveArrest_Button.setOnClickListener(this);
cancelArrest_Button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.bAgencyInfo:
startActivity(new Intent(this,AgencyPop.class));
break;
}
}
第二个弹出窗口:
public class AgencyPop extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.agency_popup);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
getWindow().setLayout((int)(width*.8),(int)(height*.6));
}
}