前年做新闻类客户端时,想实现自定义几个模板的视图轮留切换显示,在当时也不知道能不能实现,所以先用javascript写了一段模拟真实,看上去还不错,之后就将它翻成objective-c了,项目完成。
2 <HTML>
3 <HEAD>
4 <TITLE> New Document </TITLE>
5 <META NAME="Generator" CONTENT="EditPlus">
6 <META NAME="Author" CONTENT="">
7 <META NAME="Keywords" CONTENT="">
8 <META NAME="Description" CONTENT="">
9 </HEAD>
10
11 <BODY>
12 <SCRIPT LANGUAGE="JavaScript">
13 <!--
14
15
16
17 var totalPage = 0;
18 var vcArray = [];
19 var news = [0,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];
20 var layoutArray = [
21 {
22 vc:"_7",
23 pageSize :7
24 },
25 {
26 vc:"_8",
27 pageSize : 8
28 },
29 {
30 vc:"_9",
31 pageSize :9
32 }
33 ];
34
35 var newsRetainCount = news.length;
36 while(newsRetainCount > 0)
37 {
38 for(var i=0; i<layoutArray.length;i++)
39 {
40 newsRetainCount -= layoutArray[i].pageSize;
41 vcArray.push(layoutArray[i]);
42 if(newsRetainCount<=0) break;
43 }
44 }
45
46 document.writeln("totalpage:"+vcArray.length + " <br/>");
47 document.writeln("totalNews:"+news.length + " <br/>");
48 document.writeln("layoutTemlate:"+vcArray.length + " <br/>");
49 for(var ele in vcArray)
50 {
51 document.writeln(vcArray[ele].vc + "<br/>");
52 }
53
54 //返回指定页面索引的新闻数组(索引基数为1).
55 function getNewsAtPageIndex(iPageIndex)
56 {
57 var iPageSize = 0;
58 var iBeginIndex = 4;
59 var iPageSizeCount = 0;
60
61 if(iPageIndex == 1) //如果是第一页就返回前4条记录即可.
62 {
63 return news.slice(0, iBeginIndex);
64 }
65 else //循环分页视图控制器数组,将新闻数累加,结束点为指定索引页面的视图控件器尽寸.
66 {
67 iPageIndex -=2;
68 for(var i=0; i < vcArray.length; i++)
69 {
70 if(i==iPageIndex)break;
71 iPageSizeCount += vcArray[i].pageSize;
72 }
73 iPageSize = vcArray[iPageIndex].pageSize;
74 }
75 return news.slice(iBeginIndex + iPageSizeCount, iBeginIndex + iPageSizeCount + iPageSize);
76 }
77
78 for(var i=0; i<vcArray.length;i++)
79 {
80 document.writeln("<br/><br/>Page "+(i+1)+":<br/>")
81 var news_page = getNewsAtPageIndex(i+1);
82 for(var ele in news_page)
83 {
84
Android状态栏通知Status Bar Notification
状态栏通知最典型的一种就是当收到短信时会在状态栏上显示一个通知,可
以用鼠标点击状态栏并向下拖动,以查看是否有新的状态栏通知。
文章来源:好岸园it技术网 http://www.hopean.com
strings.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">ANotificationDemo</string> <string name="hello_world">Hello world!</string> <string name="menu_settings">Settings</string> <string name="send">发送通知</string> </resources>
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/send" android:id="@+id/button" /> </RelativeLayout>
java代码如下
MainActivity.java
package com.example.anotificationdemo; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = (Button)findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @SuppressWarnings("deprecation") @Override public void onClick(View v) { //获取通知管理器 NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int icon = android.R.drawable.sym_action_email; long when = System.currentTimeMillis(); //新建一个通知,指定其图标和标题 //第一个参数为图标,第二个参数为标题,第三个为通知时间 @SuppressWarnings("deprecation") Notification notification = new Notification(icon, null, when); notification.defaults = Notification.DEFAULT_SOUND;//发出默认声音 //当点击消息时就会向系统发送 openintent 意图 PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this, 0, null, 0); notification.setLatestEventInfo(MainActivity.this, "通知", "今天下午 5 点全体人员到会议室开会!", contentIntent); mNotificationManager.notify(0, notification);//发送通知 } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
修改完成后就能运行出所要的结果了
源码下载:ANotificationDemo
我的bootloader用的是飞凌公司提供的2440BOOT_V5.1,想降频,我是直接修改了inc/Option.inc文件的
这是没有修改过的
;(3) Select FCLK
;FCLK SETA296352000;FCLK SETA 271500000
;FCLK SETA 100000000
;FCLK SETA 240000000
;FCLK SETA 280000000
;FCLK SETA 320000000
;FCLK SETA 360000000
FCLK SETA400000000
我是直接把FClK SETA 400000000给注释掉了,把FCLK SETA 100000000给打开。重新编译通过H-Jtag烧写到nandflash。
但是bootloader启动不起来,H-Jtag能识别CPU,但是识别不了nandflash。H-flasher提示如下错误
error:can't halt target and make it enter DEBUG state.....并且LED灯也不正常(全部亮)。。。。。
不能停止目标CPU,说明你的CPU程序已经在运行了。但是运行程序不正确。
能检测到CPU,说明JTAG连接正确,CPU供电OK
解决办法:
一:调节板的OM脚,不要让它从Nand启动,如调成从NOR启动,这时,IROM就不会将Nand里的错误程序拷到DRAM并运行了。然后再试试h-flash,检测nand,烧入正确的程序。
二:直接换一块新的或者全部格过的flash,再试。如果第二步仍然不行,检查2440的大小页配置问题。
三:使用JLINK,通过halt命令停止CPU的运行,然后导入一个初始化BIN文件并运行,再通过h-jtag引导正确的boot在DRAM运行
我采用的是第一种方法,把nand跟nor的管脚跳线设置为nor启动,然后就识别了nandflash芯片。
造成这个的原因后来查证是,FCLK:HCLK:PCLK= 1:4:8采用的分频形式,也就是主频400MHz,HCLK为100MHz,PCLK为50MHz
FCLK is used by ARM920T,内核时钟,主频。
HCLK is used for AHB bus, which is used by the ARM920T, the memory controller, the interrupt controller, the LCD controller, the DMA and USB host block. 也就是总线时钟,包括USB时钟。
PCLK is used for APB bus, which is used by the peripherals such as WDT, IIS, I2C, PWM timer, MMC interface,ADC, UART, GPIO, RTC and SPI.即IO接口时钟,例如串口的时钟设置就是从PCLK来的;
我只是修改了FCLK为100MHz,但是比值关系没有改,相应的HCLK为50MHz,PCLK为12.5MHz。
大概过程如下,这些值在外部晶振12MHz的基础上通过PLL的作用倍频到我们需要的核心频率如400MHz,由于该频率过高,需要通过对预分频器进行适当的设置获取外围设备能够正常工作的频率如HCLK 100MHz、PLCK 50MHz。
Fclk(给CPU核供给时钟信号,我们所说的s3c2410的cpu主频为200MHz,就是指的这个时钟信号,相应的,1/Fclk即为cpu时钟周期)、Hclk(为AHB bus peripherals供给时钟信号,AHB为advanced high-performance bus)、Pclk(为APB bus peripherals供给时钟信号,APB为advanced peripherals bus)。
AHB总线连接高速外设,低速外设则通过APB总线互连。显然,对不同总线上的外设,应该使用不同的时钟信号,AHB总线对应Hclk,APB总线对应Pclk。那么事先就应该弄清楚,每条总线对应的外设有那些,这样在设置好时钟信号后,对应外设的初始化的值就要依此而确定了。