*

【android】DrawableとBitmap、リソースの相互変換 

公開日: : android

Resource → Bitmap

Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.icon)

Resource → Drawable

Drawable draw = getResources().getDrawable(R.drawable.icon)

Drawable → Bitmap

Bitmap bm = ((BitmapDrawable) drawable).getBitmap()

Bitmap → Drawable

Drawable draw = new BitmapDrawable(bitmap)

関連記事

no image

【android】スリープモードに入らせない

Androidでは一定時間、操作をしないとスリープモードに入って待機状態になってしまいますが、動

記事を読む

no image

[android] モンキーテスト(Monkey Test)を実行する

最近テストの効率化に目覚めました。 モンキーテストは猿にアプリを渡してみてめちゃくちゃな操作をさせ

記事を読む

no image

【android】 setOnClickListener(false)が効かない

間違いその1 OnClickListenerが登録されているViewにsetClickable

記事を読む

no image

【android】 webviewでassetsのリソースを使用する

webviewでassets内のリソースにアクセスするには file:///android_a

記事を読む

no image

インテント

基本 //任意のアクティビティの起動 Intent intent = new

記事を読む

no image

【android】リソースからいろいろ取得する

リソースで定義したいろいろをコード内で呼び出す方法です。 レイアウト //リソースからレ

記事を読む

no image

【android】アプリ内課金を実装する

アプリ内課金のサンプルコードを解析します。 参考URL 公式API Android

記事を読む

no image

【android】 年月だけのDatePicker

final DatePicker datePicker = new DatePicker(sel

記事を読む

no image

【android】言語・地域設定の取得

androidでは利用する言語と国名がjava.util.Localeのオブジェクトとして設定されて

記事を読む

no image

[android] ActivityとFragmentのライフサイクルいろいろ

Fragmentを使い始めてライフサイクル関係でハマることがあったので備忘録。 FragmentA

記事を読む

Message

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

no image
知らないと損をする6つのライセンスまとめ

オープンソースやフリーウェア、フリー素材などが巷に溢れ、それらを利用す

no image
ガリレオ:ニュースブラウザをリリースしました。

概要 ガリレオはニュースを読んだり、検索する機能に特化したブラウザア

no image
【android】Activityとプロセスのライフサイクル

またもやライフサイクル周りでハマったのですが、Androidのライフサ

→もっと見る

PAGE TOP ↑