的Android微调
问题描述:
我已经定义2个纺纱:的Android微调
<Spinner android:layout_width="fill_parent" android:layout_marginRight="10dp" android:layout_height="wrap_content" android:id="@+id/spinnerOd" android:layout_marginLeft="10dp" android:layout_below="@+id/OD"></Spinner>
<Spinner android:layout_below="@+id/DO" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/DO" android:layout_alignRight="@+id/DO" android:id="@+id/spinnerDo"></Spinner>
接下来是填充具有相同数据都纱厂(它们被用来选择日期范围和数据是相同的)一个代码...
Spinner sOd = (Spinner)findViewById(R.id.spinnerOd);
Spinner sDo = (Spinner)findViewById(R.id.spinnerDo);
final sOdDATA items[] = new sOdDATA[9];
long Today = System.currentTimeMillis();
for (int i = 0; i < 9; i++) {
long makeDate = Today + ((i - 1)*(24*60*60*1000));
SimpleDateFormat thisDateFormater = new SimpleDateFormat("dd.MM.yyyy");
SimpleDateFormat dayFormater = new SimpleDateFormat("E");
String SloDay = "";
if(thisDateFormater.format(makeDate).equals(thisDateFormater.format(Today)))
{
SloDay = "Danes";
}
else
{
if(thisDateFormater.format(makeDate).equals(thisDateFormater.format(Today - ((24*60*60*1000)))))
{
SloDay = "Včeraj";
}
else
{
if(thisDateFormater.format(makeDate).equals(thisDateFormater.format(Today + ((24*60*60*1000)))))
{
SloDay = "Jutri";
}
else
{
SloDay = returnSLODayName(dayFormater.format(makeDate));
}
}
}
thisDateFormater.format(makeDate);
items[i] = new sOdDATA(SloDay + ", " + thisDateFormater.format(makeDate) ,thisDateFormater.format(makeDate).toString());
}
ArrayAdapter<sOdDATA> adapter =
new ArrayAdapter<sOdDATA>(
this,
android.R.layout.simple_spinner_item,
items);
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
sOd.setAdapter(adapter);
sOd.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int position,
long id) {
sOdDATA d = items[position];
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
ArrayAdapter<sOdDATA> adapterDo =
new ArrayAdapter<sOdDATA>(
this,
android.R.layout.simple_spinner_item,
items);
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
sDo.setAdapter(adapterDo);
sDo.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int position,
long id) {
sOdDATA d = items[position];
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
我的结果是下一个:
微调1:
微调2:
什么是错的微调2?
答
你错过了setDropDownResource()
...第二一个....
+0
德姆:)多么愚蠢的错误...如果在定义2个相同的纺纱厂时出现问题,我正在网上搜索......谢谢你! – 2011-05-23 12:35:54
+0
它发生交配...下次照顾.. – ngesh 2011-05-23 12:37:21
试举宽度在第二微调 – Lavanya 2011-05-23 12:28:47
仍然是相同的XML文件FILL_PARENT ...是有可能,这种情况发生,因为我用2 spinners具有相同的定义? – 2011-05-23 12:33:55
@ M.V。请看看这个问题:http://*.com/questions/21526982/how-to-create-spinner-to-show-current-and-next-30-dates – Sun 2015-06-30 12:21:52