-
Notifications
You must be signed in to change notification settings - Fork 1
/
DateCheckBoxDialog.java
88 lines (75 loc) · 2.57 KB
/
DateCheckBoxDialog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.tudaidai.tuantrip;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import com.tudaidai.tuantrip.types.DatePrice;
import com.tudaidai.tuantrip.types.Group;
import com.tudaidai.tuantrip.widget.DateCheckBoxListAdapter;
public class DateCheckBoxDialog extends Dialog {
private Group<DatePrice> datePrice;
private Group<DatePrice> userBuyDatePrice;
private DateCheckBoxListAdapter dateCheckBoxListAdapter;
private ListView listview;
public DateCheckBoxDialog(Context paramContext, Group<DatePrice> datePrice,
Group<DatePrice> userBuyDatePrice) {
super(paramContext);
this.datePrice = datePrice;
this.userBuyDatePrice = userBuyDatePrice;
}
public Group<DatePrice> getDatePrice() {
return this.userBuyDatePrice;
}
public void ensureUI() {
listview = (ListView) findViewById(R.id.dateListView);
dateCheckBoxListAdapter = new DateCheckBoxListAdapter(
this.getContext(), userBuyDatePrice);
dateCheckBoxListAdapter.setGroup(datePrice);
listview.setAdapter(dateCheckBoxListAdapter);
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// DateCheckBoxListAdapter.ViewHolder viewHolder =
// (DateCheckBoxListAdapter.ViewHolder)view.getTag();
// viewHolder.checkBox.setChecked(!viewHolder.checkBox.isChecked());
}
});
Button dateButton = (Button) findViewById(R.id.dateCheckBoxButton);
dateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
userBuyDatePrice = dateCheckBoxListAdapter.getDatePrice();
// int count = listview.getCount();
// for(int i = 0; i < count; i++)
// {
// LinearLayout layout = (LinearLayout)listview.getChildAt(i);
// int c = layout.getChildCount();
// for(int j = 0; j < c; j++)
// {
// View view = layout.getChildAt(j);
// if(view instanceof CheckBox)
// {
// CheckBox checkBox = (CheckBox)view;
// if(checkBox.isChecked())
// {
// userBuyDatePrice.add((DatePrice)checkBox.getTag());
// }
// }
// }
// }
cancel();
}
});
}
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.date_checkbox_dialog);
setTitle("选择日期");
ensureUI();
}
}