在我的应用程序中,我在一个活动中使用了不止一个纺纱器,一切都很好,但当我开始另一个活动时,根据我当前活动中的纺纱器的选定项目,所有选定的纺纱器项目都自行获得对其“0”索引值的更改。当我从下一个活动返回到带有旋转器的活动时(即,当活动恢复时),它所选的值被设置为“0”索引。我怎样才能阻止旋转者在开始另一个活动时改变其选定项目的行为。
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("InterestSpinner", interest.getSelectedItemPosition());
outState.putInt("CompanySpinner", company.getSelectedItemPosition());
outState.putInt("PolicySpinner", policy.getSelectedItemPosition());
outState.putInt("DeptSpinner", dept.getSelectedItemPosition());
}
Intent intent = new Intent(PolicySelection.this, TakePicture.class);
intent.putExtra("INTERESTID", interestId);
intent.putExtra("COMPANYID", companyId);
intent.putExtra("TRANSID", transID);
intent.putExtra("UserName", username);
intent.putExtra("Password", password);
intent.putExtra("ClaimID", "");
intent.putExtra("OP", "UNDERWRITING");
startActivity(intent);
company.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View v, int position, long id) {
popDeptSpinner();
popPolicySpinner();
popInterestSpinner();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});`
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.policy_selection);
policy = (Spinner) findViewById(R.id.policySelectionSpinner);
company = (Spinner) findViewById(R.id.companySelectSpinner);
interest = (Spinner) findViewById(R.id.interestIdSpinner);
department = (Spinner) findViewById(R.id.deptSpinner);
camera = (Button) findViewById(R.id.camera);
damages = (Button) findViewById(R.id.damages);
upload = (Button) findViewById(R.id.upload);
showDetail = (Button) findViewById(R.id.showDetail);
title = (TextView) findViewById(R.id.title);
popCompanySpinner();
popDeptSpinner();
popPolicySpinner();
popInterestSpinner();
showDetail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean ready = isNetworkAvailable();
if (ready) {
if (policy.getAdapter().getCount() > 0) {
deptID = department.getSelectedItem().toString();
if (deptID.equals("MOTOR") || deptID.equals("MISCELLEANEOUS")) {
interestId = interest.getSelectedItem().toString();
transID = transId_list.get(getPositions(policy.getSelectedItem().toString()));
branchId = branchId_list.get(getPositions(policy.getSelectedItem().toString()));
deptNo = deptNoList.get(getPositions(policy.getSelectedItem().toString()));
Intent intent = new Intent(PolicySelection.this, InterestDetail.class);
intent.putExtra("UserName", username);
intent.putExtra("Password", password);
intent.putExtra("InterestID", interestId);
intent.putExtra("DeptID", deptNo);
intent.putExtra("TransID", transID);
startActivity(intent);
} else {
Toast.makeText(PolicySelection.this, "No Details for Current Policy!", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(PolicySelection.this, "No Policy Exists in Company! ", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(PolicySelection.this, "Internet Connectivity Problem!", Toast.LENGTH_SHORT).show();
}
}
});
damages.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean ready = isNetworkAvailable();
if (ready) {
if (policy.getAdapter().getCount() > 0) {
if (department.getSelectedItem().toString().equals("MOTOR")) {
Integer pos;
pos = getPositions(policy.getSelectedItem().toString());
switch (company.getSelectedItem().toString()) {
case "UIC":
transID = transId_list.get(pos);
companyId = "UIC";
surveyTransID = UICSurveyTransID.get(getInterestIdPositions(interest.getSelectedItem().toString()));
break;
case "UICTAK":
transID = transId_list.get(pos);
companyId = "UICTAK";
surveyTransID = UICTAKSurveyTransID.get(getInterestIdPositions(interest.getSelectedItem().toString()));
break;
case "SPI":
transID = transId_list.get(pos);
companyId = "SPI";
surveyTransID = SPISurveyTransID.get(getInterestIdPositions(interest.getSelectedItem().toString()));
break;
case "SPITAK":
transID = transId_list.get(pos);
companyId = "SPITAK";
surveyTransID = SPITAKSurveyTransID.get(getInterestIdPositions(interest.getSelectedItem().toString()));
break;
default:
break;
}
Intent intent = new Intent(PolicySelection.this, DamagesDetail.class);
if (Objects.equals(transID, "")) {
company.getSelectedItem().toString();
} else {
String options = new WebServiceCall().getPreInspectionOptions("GetPreInspectionOptions", username, password, companyId, transID);
intent.putExtra("TRANSID", transID);
intent.putExtra("COMPANYID", companyId);
intent.putExtra("UserName", username);
intent.putExtra("Password", password);
intent.putExtra("Options", options);
intent.putExtra("SurveyTransID", surveyTransID);
}
startActivity(intent);
} else {
Toast.makeText(PolicySelection.this, "No Damages Form for Current Policy!", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(PolicySelection.this, "No Policy Exists in Company! ", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(PolicySelection.this, "Internet Connectivity Problem!", Toast.LENGTH_SHORT).show();
}
}
});
upload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean ready = isNetworkAvailable();
if (ready) {
if (policy.getAdapter().getCount() > 0) {
Integer pos;
pos = getPositions(policy.getSelectedItem().toString());
switch (company.getSelectedItem().toString()) {
case "UIC":
transID = transId_list.get(pos);
branchId = branchId_list.get(pos);
break;
case "UICTAK":
transID = transId_list.get(pos);
branchId = branchId_list.get(pos);
break;
case "SPI":
transID = transId_list.get(pos);
branchId = branchId_list.get(pos);
break;
case "SPITAK":
transID = transId_list.get(pos);
branchId = branchId_list.get(pos);
break;
default:
break;
}
Intent intent = new Intent(PolicySelection.this, SendInfoForm.class);
intent.putExtra("USERNAME", username);
intent.putExtra("PASSWORD", password);
intent.putExtra("COMPANYID", company.getSelectedItem().toString());
intent.putExtra("LAT", "1");
intent.putExtra("LONG", "1");
intent.putExtra("DEPTID", department.getSelectedItem().toString());
intent.putExtra("INTERESTID", interest.getSelectedItem().toString());
intent.putExtra("BRANCHID", branchId);
intent.putExtra("TRANSID", transID);
intent.putExtra("OP", "UNDERWRITING");
intent.putExtra("CLAIMID", "");
startActivity(intent);
} else {
Toast.makeText(PolicySelection.this, "No Policy Exists in Company! ", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(PolicySelection.this, "Internet Connectivity Problem!", Toast.LENGTH_SHORT).show();
}
}
});
camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (policy.getAdapter().getCount() > 0) {
Integer pos;
pos = getPositions(policy.getSelectedItem().toString());
if (policyList != null) {
if (Objects.equals(SelectedPolicy, " ")) {
SelectedPolicy = company.getSelectedItem().toString();
}
}
switch (company.getSelectedItem().toString()) {
case "UIC":
interestId = interest.getSelectedItem().toString();
companyId = "UIC";
transID = transId_list.get(pos);
break;
case "UICTAK":
interestId = interest.getSelectedItem().toString();
companyId = "UICTAK";
transID = transId_list.get(pos);
break;
case "SPI":
interestId = interest.getSelectedItem().toString();
companyId = "SPI";
transID = transId_list.get(pos);
break;
case "SPITAK":
interestId = interest.getSelectedItem().toString();
companyId = "SPITAK";
transID = transId_list.get(pos);
break;
default:
break;
}
Intent intent = new Intent(PolicySelection.this, TakePicture.class);
intent.putExtra("INTERESTID", interestId);
intent.putExtra("COMPANYID", companyId);
intent.putExtra("TRANSID", transID);
intent.putExtra("UserName", username);
intent.putExtra("Password", password);
intent.putExtra("ClaimID", "");
intent.putExtra("OP", "UNDERWRITING");
startActivity(intent);
} else {
Toast.makeText(PolicySelection.this, "No Policy Exists in Company! ", Toast.LENGTH_LONG).show();
}
}
});
company.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View v, int position, long id) {
popDeptSpinner();
popPolicySpinner();
popInterestSpinner();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
policy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View v, int position, long id) {
if (policyList != null) {
SelectedPolicy = policy.getSelectedItem().toString();
policy.setSelection(position);
popInterestSpinner();
}
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
interest.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
if (interestList != null) {
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
department.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
popPolicySpinner();
popInterestSpinner();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
如何使用SaveInstanceState
@Override
public void onSaveInstanceState(Bundle outState) {//store your instance here
outState.putString("message", "This is my message to be reloaded");
super.onSaveInstanceState(outState);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {//load your instance here
int position= savedInstanceState.getInt("InterestSpinner",0);
spinner.setSelection(interestSpiner);
}
}
或
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
int position= savedInstanceState.getInt("InterestSpinner",0);
spinner.setSelection(interestSpiner);
}
问题内容: 我正在使用实质性的UI Select组件,并且试图在内部构建过滤器以仅显示与用户输入的内容匹配的项目。 我为正在开发的内容构建了一个最小的示例。 现在我的问题是,默认情况下,选择组件允许用户按下任何字母,并且如果存在第一个字母与用户输入匹配的选项,它将选择该选项。 所以,如果我有3个选项(,和)和用户类型选择部件将选择选项,我的文本字段不会改变的价值。但是,如果用户键入,则文本字段将更
本文向大家介绍Django 开始一个项目,包括了Django 开始一个项目的使用技巧和注意事项,需要的朋友参考一下 示例 Django是一个基于Python的Web开发框架。Django的1.11(最新的稳定版本)需要Python 2.7,3.4,3.5或3.6安装。假设pip可用,安装就像运行以下命令一样简单。请记住,省略如下所示的版本将安装django的最新版本: 为了安装特定版本的djang
项目初始化 创建 Http Server 项目:composer create-project imiphp/project-http 创建 WebSocket Server 项目:composer create-project imiphp/project-websocket 创建 TCP Server 项目:composer create-project imiphp/project-tcp
我有两个碎片,两个碎片上都有一个按钮。当我按下按钮时,我想开始一项新的活动。但我不能让它工作。 我得到的错误:这里的错误:类型不匹配:无法从mFragmentFavorite转换为片段 我做错了什么? 我的碎片寻呼机适配器 收藏夹 如果FavoriteActivity扩展了片段,那么错误就消失了,但是我在findViewById(R.id.mainFavorite)处得到了一个错误 错误为 fin
以下代码起作用: 如何将第二行重构为: 您对所选的******选项使用了什么?
此组件来自https://github.com/skratchdot/react-bootstrap-multiselect handleChange()函数中应该写什么?