我正在设计药物提醒应用程序,我选择使用微调器,以便用户可以选择“每天一次”,“每天两次”或“每天三次”。
然后我想根据需要使用旋转器的答案来创建1,2或3个时间戳。
唯一的问题是我真的被困在如何做到这一点。
有人可以指出我正确的方向吗?
非常感谢
萨拉
答案 0 :(得分:0)
您可以在strings.xml中创建数组
function preFilterLookup() {
var accountId = Xrm.Page.getAttribute("parentaccountid").getValue();
Xrm.Page.getControl("my_lookup_field").addPreSearch(function () {
addFilter(accountId);
});
}
Spinner arrayadapter适配器
<string-array name="time_arrays">
<item>Once A Day</item>
<item>Twice A Day</item>
<item>Three Times A Day</item>
</string-array>
答案 1 :(得分:0)
<强>初始化强>
private Spinner spnSemester;
ArrayAdapter<String> timeAdapter;
List<String>courseList= new ArrayList<>();
spnTime = (Spinner) findViewById(R.id.spnTime);
courseList.add("Once A Day");
courseList.add("Twice A Day");
courseList.add("Thrice A Day");
timeAdapter= new ArrayAdapter<String>(
this,android.R.layout.simple_spinner_item,courseList);
spnTime.setAdapter(timeAdapter);
timeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
点击“侦听器”以获取值
spnTime.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//Store selected value here
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
答案 2 :(得分:0)
最初设计声明Spinner
和TimePicker
的xml布局,有关Spinner
here
然后根据需要隐藏并显示timePicker。
public class MainActivity extends Activity implements
AdapterView.OnItemSelectedListener {
String[] spinner_values = { "Once A Day", "Twice A Day", "Three Times A Day" };
@Override
protected void onCreate(Bundle savedInstanceState) {
//setup timepickers as required
timepicker1=(TimePicker)findViewById(R.id.timePicker1);
timepicker2=(TimePicker)findViewById(R.id.timePicker2);
timepicker3=(TimePicker)findViewById(R.id.timePicker3);
//initially set visibility to GONE for all three timers
//setup spinner
Spinner spinner = (Spinner) findViewById(R.id.spinner1);
spinner.setOnItemSelectedListener(this);
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, spinner_values);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position,long id) {
Switch(position){
case 2 :
//show timePicker3
case 1:
//show timepicker2
case 0:
//show timePicker1
break;
default
//hide all timerPickers
break;
}
}
}