ページ

2011/02/22

Android ライブ壁紙設定画面の背景色

|
以下のページを参考に、ライブ壁紙の設定画面(PreferenceActivity)を作成しました。
http://developer.android.com/resources/samples/CubeLiveWallpaper/AndroidManifest.html

この場合、設定画面の背景が半透明になり、後ろの画面が透けて見えます。
通常の不透明な画面にする方法を探していたのですが、AndroidManifest.xmlの以下の設定を修正するだけでした。

android:theme="@android:style/Theme.Light.WallpaperSettings"

以下のページに記載されている、Androidで提供されているテーマTheme_Blackを使用すれば通常の黒い画面になります。
http://developer.android.com/reference/android/R.style.html

AndroidManfest.xmlに書く場合には、Theme.Blackと「.」で区切るようです。

android:theme="@android:style/Theme.Black"

2011/02/19

Android Menuサンプル

|
メニューのサンプルを作成しました。

実行イメージ:


Android Listサンプル

|
Androidでリスト表示をするサンプルを作成しました。

実行イメージ:

ListActivityを継承して作成します。


package com.example.listviewsample;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class ListViewSampleActivity extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // レイアウトは不要
        //setContentView(R.layout.main);
        
        // アダプタに項目を設定
        setListAdapter(new ArrayAdapter(
          this,
          android.R.layout.simple_list_item_1,
          new String[]{
            "item1",
            "item2",
            "item3",
          }));
    }
}