java日歷事件處理_日歷表的事件處理和管理(劉靜)

1 //添加gridview,顯示具體的日期

2 @SuppressLint("ResourceAsColor")3 private voidaddGridView() {4 LinearLayout.LayoutParams params = newLinearLayout.LayoutParams(5 LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);6 //取得屏幕的寬度和高度

7 WindowManager windowManager =getWindowManager();8 Display display =windowManager.getDefaultDisplay();9 int Width =display.getWidth();10 int Height =display.getHeight();11

12 Log.d(Tag, "屏幕分辨率=="+"height*weight"+Height+Width);13

14 gridView = new GridView(this);15 gridView.setNumColumns(7);16 gridView.setColumnWidth(46);17 if(Width == 480 && Height == 800){18 gridView.setColumnWidth(69);19 }else if(Width==800&&Height==1280){20 gridView.setColumnWidth(69);21 }22

23

24 gridView.setGravity(Gravity.CENTER_VERTICAL);25 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); //去除gridView邊框

26 gridView.setVerticalSpacing(1);27 gridView.setHorizontalSpacing(1);28 gridView.setBackgroundResource(R.drawable.gridview_bk);29 gridView.setOnTouchListener(newOnTouchListener() {30 //將gridview中的觸摸事件回傳給gestureDetector

31

32 public booleanonTouch(View v, MotionEvent event) {33 //TODO Auto-generated method stub

34 return CalendarActivity.this.gestureDetector35 .onTouchEvent(event);36 }37 });38

39

40 gridView.setOnItemClickListener(newOnItemClickListener() {41 //gridView中的每一個item的點擊事件

42

43 public void onItemClick(AdapterView> arg0, View arg1, intposition,44 longarg3) {45 //點擊任何一個item,得到這個item的日期(排除點擊的是周日到周六(點擊不響應))

46 int startPosition =calV.getStartPositon();47 int endPosition =calV.getEndPosition();48 if(startPosition <= position && position <=endPosition){49 String scheduleDay = calV.getDateByClickItem(position).split("\\.")[0]; //這一天的陽歷50 //String scheduleLunarDay = calV.getDateByClickItem(position).split("\\.")[1];//這一天的陰歷

51 String scheduleYear =calV.getShowYear();52 String scheduleMonth =calV.getShowMonth();53 String week = "";54

55 Log.i("日程歷史瀏覽", scheduleDay);56

57 //通過日期查詢這一天是否被標記,如果標記了日程就查詢出這天的所有日程信息

58 scheduleIDs =dao.getScheduleByTagDate(Integer.parseInt(scheduleYear)59 , Integer.parseInt(scheduleMonth), Integer.parseInt(scheduleDay));60

61 //得到這一天是星期幾

62 switch(position%7){63 case 0:64 week = "星期日";65 break;66 case 1:67 week = "星期一";68 break;69 case 2:70 week = "星期二";71 break;72 case 3:73 week = "星期三";74 break;75 case 4:76 week = "星期四";77 break;78 case 5:79 week = "星期五";80 break;81 case 6:82 week = "星期六";83 break;84 }85

86 scheduleDate = new ArrayList();87 scheduleDate.add(scheduleYear);88 scheduleDate.add(scheduleMonth);89 scheduleDate.add(scheduleDay);90 scheduleDate.add(week);91

92

93 LayoutInflater inflater=getLayoutInflater();94 View linearlayout= inflater.inflate(R.layout.schedule_detail, null);95 add=(Button)linearlayout.findViewById(R.id.btn_add);96 quit=(Button) linearlayout.findViewById(R.id.btn_back);97 day_tv=(TextView) linearlayout.findViewById(R.id.todayDate);98 launarDay=(TextView)linearlayout.findViewById(R.id.tv_launar);99 schdule_tip=(com.dream.tdzhushou.base.BorderTextView)linearlayout.findViewById(R.id.schdule_tip);100 listView=(ListView)linearlayout.findViewById(R.id.schedulelist1);101 //星期

102 weekday=(TextView)linearlayout.findViewById(R.id.dayofweek);103 //農歷日期

104 lunarTime=(TextView)linearlayout.findViewById(R.id.lunarTime);105 list=(ListView)linearlayout.findViewById(R.id.schedulelist1);106

107 dateInfo=scheduleYear+"年"+scheduleMonth+"月"+scheduleDay+"日";108 //添加農歷信息

109 String scheduleLunarDay =getLunarDay(Integer.parseInt(scheduleYear),110 Integer.parseInt(scheduleMonth), Integer.parseInt(scheduleDay));111

112 Log.i("LunarDay", scheduleLunarDay);113 //設置選中的日期的陽歷,星期和農歷信息

114 day_tv.setText(dateInfo);115 weekday.setText(week);116 addLunarDayInfo(lunarTime);117 launarDay.setText( scheduleLunarDay);118

119 Log.i("scheduleDate", "scheduleDate的所有信息:"+scheduleDate);120 //添加日程按鈕121 //TableLayout dialog_tab=(TableLayout) linearlayout.findViewById(R.id.dialog_tab);

122 add.setOnClickListener(newOnClickListener() {123

124 public voidonClick(View v) {125 //TODO Auto-generated method stub

126 if(builder!=null&&builder.isShowing()){127 builder.dismiss();128 Intent intent = newIntent();129 intent.putStringArrayListExtra("scheduleDate", scheduleDate);130 intent.setClass(CalendarActivity.this, ScheduleViewAddActivity.class);131 startActivity(intent);132 }133 }134 });135 //返回按鈕

136 quit.setOnClickListener(newOnClickListener() {137

138 public voidonClick(View v) {139 //TODO Auto-generated method stub

140 if(builder!=null&&builder.isShowing()){141 builder.dismiss();142 }143 }144 });145

146 //如果被標記,則加載相應的日程信息列表

147 if(scheduleIDs != null && scheduleIDs.length > 0){148

149

150 //list.setAdapter(new MyAdapter());

151 View inflate=getLayoutInflater().inflate(R.layout.schedule_detail_item, null);152 //通過arraylist綁定數據導listview中去

153 ArrayList> Data = new ArrayList>();154 ScheduleDAO dao=new ScheduleDAO(CalendarActivity.this);155 String time="";156 String content="";157 for(int i=0;i

162 time=dateInfo+" "+scheduleVO.getTime();163 content=scheduleVO.getScheduleContent();164

165

166

167 HashMap map=new HashMap();168 map.put("date", time);169 map.put("content", content);170 Data.add(map);171

172 }173 String from[]={"date","content"};174 int to[]={R.id.itemTime,R.id.itemContent};175

176 SimpleAdapter adapter=new SimpleAdapter(CalendarActivity.this, Data, R.layout.schedule_detail_item, from, to);177

178 list.setAdapter(adapter);179

180 //點擊list的item相應事件181 //list.setOnClickListener(CalendarActivity.this);182 //list.setOnLongClickListener(CalendarActivity.this);

183

184

185 }else{ //如果沒有標記位直接則跟換為“暫無安排”

186

187

188 schdule_tip.setText("暫無安排");189 listView.setVisibility(View.INVISIBLE);190

191

192 }193

194 builder = new Dialog(CalendarActivity.this,R.style.FullScreenDialog);195 builder.setContentView(linearlayout);196 WindowManager windowManager =getWindowManager();197 Display display =windowManager.getDefaultDisplay();198 WindowManager.LayoutParams lp =builder.getWindow().getAttributes();199 lp.width = (int)(display.getWidth()); //設置寬度

200 lp.height=display.getHeight();201 builder.getWindow().setAttributes(lp);202 builder.setCanceledOnTouchOutside(true);203 builder.show();204

205 list.setOnItemClickListener(newOnItemClickListener() {206

207 @Override208 public void onItemClick(AdapterView>adapterview,209 View view, int position, longid) {210

211

212 Log.i("日程item點擊", "第"+position+"個item");213 Intent intent=newIntent();214

215 if(view!=null){216

217 HashMap map=(HashMap) adapterview.getItemAtPosition(position);218

219 ScheduleVO scheduleVO= (ScheduleVO) view.getTag();//

220 Log.i("scheduleVo", "scheduleVO的值="+scheduleVO);221

222 if(scheduleDate!=null){223 //intent.putStringArrayListExtra("scheduleDate", scheduleDate);

224 intent.setClass(CalendarActivity.this,ScheduleInfoDetailActivity.class);225 intent.putStringArrayListExtra("scheduleDate", scheduleDate);226 intent.putExtra("scheduleVO", scheduleVO);227

228 Log.i("scheduleVo", "往intent存放的值"+scheduleVO);229 startActivity(intent);230

231 }232 }233

234 }235 });236 }237 }238 });239 gridView.setLayoutParams(params);240 }241

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/533220.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/533220.shtml
英文地址,請注明出處:http://en.pswp.cn/news/533220.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

java第四次上機作業_第十java上機作業

第十java上機作業 第七章上級作業 7.1 public class Rectangle { double width1; double height1; String color“white“; public Rectangle(){} public Rectangle(double width,double height,String color) { this.widthwidth; this.heightheight; this.colorcolor; } publi…

java解析帶斜杠的參數_Java Spring MVC應用程序僅接受帶有斜杠的POST請求

war文件名是forms.war。 web.xml中的url模式為"/"控制器操作的RequestMapping為"/"如果遇到localhost&#xff1a;8080 /表單&#xff0c;則RequestMethod.GET操作正常工作如果針對localhost:8080/forms點擊發布數據&#xff0c;則不會觸發RequestMethod.P…

java文件編碼格式環境變量_Jenkins maven 構建亂碼,修改file.encoding系統變量編碼為UTF-8...

一切都是windows的控制臺默認編碼GBK問題情景&#xff1a;使用jenkins構建&#xff0c;console 輸出的中文亂碼。代碼編碼格式是utf-8&#xff0c;因為Jenkins會默認讀取當前系統的編碼格式&#xff0c;導致構建日志亂碼和selenium自動化測試輸入的中文亂碼。控制臺輸出亂碼摸索…

http multipart java_Http MultiPart請求

我正在嘗試使用httpClient庫上傳圖像(多部分/表單數據) . 我可以使用httpPost方法和byteArrayRequestEntity上傳圖像 . 以下是我使用的代碼&#xff1a;File file new File(imageFilePath);HttpClient client new HttpClient();PostMethod method new PostMethod("http…

java分布式會話redis_詳解springboot中redis的使用和分布式session共享問題

對于分布式使用NginxTomcat實現負載均衡&#xff0c;最常用的均衡算法有IP_Hash、輪訓、根據權重、隨機等。不管對于哪一種負載均衡算法&#xff0c;由于Nginx對不同的請求分發到某一個Tomcat&#xff0c;Tomcat在運行的時候分別是不同的容器里&#xff0c;因此會出現session不…

python3.8使用方法_python3.8新特性

python3.8新特性Python3.8穩定版已發布&#xff0c;官網發布了一篇介紹新特性的文章&#xff0c;在此記錄一下。新增賦值操作符:作用&#xff1a;把較大表達式中的某部分值賦給變量,因為看起來像海象的眼睛和牙齒&#xff0c;: 操作符有個特別的名字&#xff1a;海象操作符范例…

java責任鏈設計模式 訂單_Java責任鏈設計模式實例分析

本文實例講述了Java責任鏈設計模式。分享給大家供大家參考&#xff0c;具體如下&#xff1a;一 代碼abstract class AbstractHandler {private Handler Handler null;// 持有責任鏈中下一個責任處理者的引用public void setHandler( Handler handler ) {this.Handler handler…

java map去重復的數據_使用HashMap去重復數據.

因為HashMap是鍵值對形式&#xff0c;所以一個鍵只對應一個Value&#xff0c;利用這個原理&#xff0c;我們就可以根據某列重復數據做鍵對重復數據進行處理啦~首先先看看我要處理 的數據然后我最后想要的結果&#xff1a;需求&#xff1a;根據groupName每個分組信息只顯示一條數…

centos6.5 MySQL 服務器_啟用CentOS6.5 64位安裝時自帶的MySQL數據庫服務器

本人在虛擬機上又安裝了一臺linux機器&#xff0c;作為MySQL數據庫服務器用&#xff0c;在安裝時選擇了系統自帶的MySQL服務器端&#xff0c;以下是啟用步驟。首先開啟mysqld服務#service mysqld start進入/usr/bin目錄#cd /usr/bin設定mysql數據庫root用戶的密碼#mysqladmin -…

java xml date_W3C XML 模式時間數據類型與java Date進行轉換

W3C XML 模式時間數據格式:"2014-11-17T 09:40:25" 或者 “2014-11-17T 09:40:2508:00”要想把以上格式的時間轉換為能被java所使用個格式有以下3種辦法&#xff1a;(1)、jdk中有這么一個類XMLGregorianCalendar&#xff0c;使用XMLGregorianCalendar類中的toGreGreg…

PHP stomp 連接判斷,php實現通過stomp協議連接ActiveMQ操作示例

本文實例講述了php實現通過stomp協議連接ActiveMQ操作。分享給大家供大家參考&#xff0c;具體如下&#xff1a;前面介紹了php ActiveMQ的安裝與使用&#xff0c;這里再來講述一下php通過stomp協議連接ActiveMQ。一、安裝php的stomp擴展http://pecl.php.net/package/stomp如&am…

authinfo.php,【nginxphp】后臺權限認證方式

一、最常用的方法(代碼中限制)1、如何限制IPfunction get_new_ip(){if(getenv(HTTP_CLIENT_IP)) {$onlineip getenv(HTTP_CLIENT_IP);} elseif(getenv(HTTP_X_FORWARDED_FOR)) {$onlineip getenv(HTTP_X_FORWARDED_FOR);} elseif(getenv(REMOTE_ADDR)) {$onlineip getenv(RE…

php數組無限文類,php把無限級分類生成數組的類

你是否遇到需要把無限級分類循環出來&#xff0c;是不是很頭痛。比如&#xff0c;要循環出一個SELECT,或一個TABLE&#xff0c;要寫一大堆判斷。我的做法是生成數組&#xff0c;可以重復調用&#xff0c;直接循環數組就行了。為了方便&#xff0c;把它寫成了類&#xff1a;clas…

php sql取數據生成數組中,php中實現數組生成要執行的sql語句

本篇文章主要介紹php中實現數組生成要執行的sql語句&#xff0c;感興趣的朋友參考下&#xff0c;希望對大家有所幫助。會不會碰到這樣一種情況呢&#xff1f;每次獲取數據將數據和歷史版本都有一定的差別&#xff0c;然而用ThinkPHP的addAll()函數&#xff0c;卻會將已有的數據…

xss漏洞php注射實戰,利用XSS滲透DISCUZ 6.1.0實戰

論壇——>入侵者布置的跨站攻擊——>轉移被入侵這視線(隱蔽)論壇插入腳本&#xff1a;var img new Image();img.src get_cookie.php?var encodeURI(document.cookie);但是我不一樣&#xff0c;因為他需要誘導人去點擊他的鏈接&#xff0c;但是現在人不是傻子&#xf…

java模塊化按需加載,JavaScript模塊化之使用requireJS按需加載

模塊加載器的概念可能稍微接觸過前端開發的童鞋都不會陌生&#xff0c;通過模塊加載器可以有效的解決這些問題&#xff1a;JS文件的依賴關系。通過異步加載優化script標簽引起的阻塞問題可以簡單的以文件為單位將功能模塊化并實現復用主流的JS模塊加載器有requireJS&#xff0c…

宇軒網絡面試題目PHP,二十道接地氣的php面試題,讓你直接通過面試!就此奉上~...

1、echo count(“abc”); 輸出什么&#xff1f;答&#xff1a;"1"count— 計算數組中的單元數目或對象中的屬性個數int count ( mixed var\[,intvar \[, intvar\[,intmode ] ), 如果 var 不是數組類型或者實現了 Countable 接口的對象&#xff0c;將返回 1&#xff0…

java期末試題c卷,JAVA程序設計期末考試試卷及參考答案

《JAVA程序設計》期末考試試卷考生注意&#xff1a;1&#xff0e;本試卷滿分100分。2&#xff0e;考試時間90分鐘。3&#xff0e;卷面整潔&#xff0c;字跡工整。4&#xff0e;填寫內容不得超出密封線。總分題號一二三四五六核分人題分21204019復查人得分一、單選擇題(每題2分&…

mysql 分組查詢原理,MySQL分組查詢Group By實現原理詳解

由於GROUP BY 實際上也同樣會進行排序操作&#xff0c;而且與ORDER BY 相比&#xff0c;GROUP BY 主要只是多了排序之后的分組操作。當然&#xff0c;如果在分組的時候還使用了其他的一些聚合函數&#xff0c;那么還需要一些聚合函數的計算。所以&#xff0c;在GROUP BY 的實現…

mysql 執行計劃詳解,Mysql中的explain執行計劃詳解(1)

創建一個表test_explain&#xff0c;并添加入下的數據mysql> create table test_explain( a int primary key, b int);Query OK, 0 rows affected (0.09 sec)mysql> insert into test_explain value(1,1),(2,2),(3,3),(4,4),(5,5);explian中的type字段&#xff1a;表示m…