我想要做的是,我要求用户从列表视图中选择一个值,然后他被重定向到另一个屏幕,该屏幕具有用户选择的默认微调器。我已经阅读了很多关于微调器默认设置的帖子,但没有一个包括从另一个屏幕获取信息,无论如何我都尝试过,但它们没有用。
这就是我从 WorkEntryScreenActivity.java 传递字符串的方式
//inside onCreate
mListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> myAdapter, View myView,
int myItemInt, long mylng) {
selectedFromList = (String) (mListView.getItemAtPosition(myItemInt));
top10 = true;
call(top10); }
});
//outside onCreate
protected void call(boolean top10){
if(top10) {
Intent i = new Intent(this, WorkEntryActivity.class);
i.putExtra("FromTab", "true");
i.putExtra("workRequest",selectedFromList);
startActivity(i);
finish();
}
}
在另一个 java 文件 WorkEntryActivity.java
//get the string
workRequestFetched = extras.getString("workRequest");
//This is where I need help
ArrayList<String> workRequestAdded = new ArrayList<String>();
workRequestSpinner = (Spinner) findViewById(R.id.workRequestSpinner);
if(workRequestFetched != null){
workRequestAdded.add(workRequestFetched);
}
ArrayList<String> workRequests = ServiceCall.workRequests;
workRequestAdded.addAll(workRequests);
final ArrayAdapter<String> workRequestAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,
workRequestAdded);
workRequestAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
workRequestSpinner.setAdapter(workRequestAdapter);