Android デバイス用の WhatsApp アプリケーションで使用されるポップアップ通知のような通知を作成したいと考えています。
どうすればできますか?私は新しいユーザーなので、スクリーンショットをアップロードできません
このリンクを参照してください: http://cdn6.staztic.com/cdn/screenshot/appsdroidnotifythemeicecreamsandwich-1-1.jpg
スクリーンショット画像と助けてください:)
Android デバイス用の WhatsApp アプリケーションで使用されるポップアップ通知のような通知を作成したいと考えています。
どうすればできますか?私は新しいユーザーなので、スクリーンショットをアップロードできません
このリンクを参照してください: http://cdn6.staztic.com/cdn/screenshot/appsdroidnotifythemeicecreamsandwich-1-1.jpg
スクリーンショット画像と助けてください:)
PopUpWindow 参照を宣言し、ポップアップ ウィンドウを開きたい場所から initializePopupWindow() メソッドを呼び出します。
private PopupWindow pwindo;
private void initiatePopupWindow() {
try {
// We need to get the instance of the LayoutInflater
LayoutInflater inflater = (LayoutInflater) PopUpWinndowDemoActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.screen_popup,
(ViewGroup) findViewById(R.id.popup_element));
pwindo = new PopupWindow(layout, 300, 370, true);
pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
次のようなポップアップ ウィンドウの screen_popup.xml を用意します。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_element"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#444444"
android:orientation="vertical"
android:padding="10sp" >
<TextView
android:id="@+id/txtView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:text="Hello!" />
</LinearLayout>