关于这一部分,必须注意sqlite的主键命名,由于simpleCursorAdapter的方法只识别_id,所以,当你用到sqlite的 simpleCursorAdapter时,必须把数据表的主键命名为_id。否则就会出现 java.lang.IllegalArgumentException: column '_id' does not exist错误。
ubuntu9.04 字体安装两种方法
文章分类:JavaEye
字体搭配:推荐安装雅黑和consolas的混合字体(见附件),宋体。firefox,gedit使用宋体,eclipse使用Courier New。其他软件一律使用雅黑。
安装方法一:运行如下命令
sudo cp 字体文件(如雅黑simsun.ttc) /usr/share/fonts/zh_CN/TrueType/
sudo chmod 644 /usr/share/fonts/zh_CN/TrueType/*
cd /usr/share/fonts/zh_CN/TrueType/
sudo mkfontscale
sudo mkfontdir
安装方法二:更简单的方法,在 home/用户名 下建立.fonts的隐藏文件夹,将字体文件拷贝到这个文件夹下即可。不过这种字体只对当前用户生效。
一个小控件转换图片
private static int layoutId; // onReceive should be something like this @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); if (bundle != null) { int newLayoutId = bundle.getInt("layout_id"); layoutId = newLayoutId; initViews(context); } else { initViews(context); } } private void initViews(Context context) { RemoteViews views = null; // Set the initial layout if (layoutId == 0) { Intent layoutIntent = new Intent("android.appwidget.action.APPWIDGET_UPDATE"); Bundle layoutBundle = new Bundle(); layoutBundle.putInt("layout_id", 1); PendingIntent lPendingIntent = PendingIntent.getBroadcast(context, 0, layoutIntent, PendingIntent.FLAG_ONE_SHOT); views = new RemoteViews(context.getPackageName(), R.layout.layout_zero); views.setOnClickPendingIntent(R.id.btnNext, lPendingIntent); } // Else if there's some trigger to change the layout... else if (layoutId == 1) { Intent layoutIntent = new Intent("android.appwidget.action.APPWIDGET_UPDATE"); Bundle layoutBundle = new Bundle(); // Since I only have two layouts, I put here the id of the previous layout layoutBundle.putInt("layout_id", 0); PendingIntent lPendingIntent = PendingIntent.getBroadcast(context, 0, layoutIntent, PendingIntent.FLAG_ONE_SHOT); views = new RemoteViews(context.getPackageName(), R.layout.layout_one); views.setOnClickPendingIntent(R.id.btnPrev, lPendingIntent); } }
2 其实简单的实践 widget_flame_with_border_off.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/main"
android:gravity="center"
android:background="@drawable/widget_frame_portrait1x1_black"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="74dip"
android:layout_width="74dip">
<LinearLayout
android:id="@+id/btn_led"
android:layout_width="52dip"
android:layout_height="52dip"
android:background="@drawable/appwidget_button_center"
android:clickable="true"
android:focusable="true"
android:gravity="center">
<ImageView
android:id="@+id/img_led"
android:layout_height="40dip"
android:layout_gravity="center"
android:layout_width="40dip"
android:src="/blog_article/@drawable/mototorch_led_off/index.html"
android:scaleType="fitXY" />
</LinearLayout>
</LinearLayout>
widget_flame_with_border_on.xml
<pre><?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/main"
android:gravity="center"
android:background="@drawable/widget_frame_portrait1x1_black"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="74dip"
android:layout_width="74dip">
<LinearLayout
android:id="@+id/btn_led"
android:layout_width="52dip"
android:layout_height="52dip"
android:background="@drawable/appwidget_button_center"
android:clickable="true"
android:focusable="true"
android:gravity="center">
<ImageView
android:id="@+id/img_led"
android:layout_height="40dip"
android:layout_gravity="center"
android:layout_width="40dip"
android:src="/blog_article/@drawable/mototorch_led_on/index.html"
android:scaleType="fitXY" />
</LinearLayout>
</LinearLayout>
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){
RemoteViews views = null;
int layoutID = 0;
if (ledIsOn){
layoutID = R.layout.widget_flame_with_border_on;
}
else {
layoutID = R.layout.widget_flame_with_border_off;
}
// the layoutID that is passed in the constructor of the
// RemoteViews object is the layout that will be loaded
// when the widget is updated.
views = new RemoteViews(context.getPackageName(), layoutID);
for (int i = 0; i < appWidgetIds.length; i++) {
appWidgetManager.updateAppWidget(appWidgetIds[i], views);
}
}