2012-05-14 30 views
0

我剛剛對android應用程序做了一個應用程序它具有NFc技術,在這裏我想創建一個Notification欄,比如默認的OS狀態欄通知。 我現在定製了它,我希望它可以在所有屏幕中調用/顯示,而最終用戶可以在應用內將其從上到下拉出。如何使用自定義滑動抽屜如android應用程序中的狀態欄通知

這是我自定義的滑動抽屜類,並用它在main.xml中我的文件

<com.abc.xyx.customnotification.CustomDrawer 
    xmlns:my="http://schemas.android.com/apk/res/com.abc.xyx.app" 
    android:id="@+id/drawer" 
    my:direction="topToBottom" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    my:handle="@+id/handle" 
    my:content="@+id/content" 
    android:layout_marginTop="100dp" 
    > 
    <include 
     android:id="@id/content" 
     layout="@layout/slider"/> 
    <ImageView 

     android:id="@id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="150px" 
     android:visibility="invisible" 

     android:src="@drawable/tooltiparea" /> 
</com.abc.xyx.customnotification.CustomDrawer> 

回答

0

你應該google一下了,也有相當多的樣品很好的解釋,像這樣的:

+0

嘿,我做到了習慣,現在我想要的確切意味着我需要在所有活動中顯示用戶是否可以在任何地方看到他的通知。 – Thamilvanan

+0

你應該展示一些代碼片段(類,佈局),你如何努力解決這個問題,以及如果有任何異常情況下的logcat輸出。 StackOverflow可以幫助你解決問題,不會爲你/而不是工作。 – rekaszeru

0

您應該使用oops

首先製作一個擴展android.app.Activity的BaseActivity。現在,這將是您希望顯示狀態欄的所有應用活動的父級活動。定義所有涉及到在自定義狀態欄以及與孩子Ativity舉行意見父佈局功能

爲BaseActivity XML佈局會是這樣

<com.abc.xyx.customnotification.CustomDrawer 
    xmlns:my="http://schemas.android.com/apk/res/com.abc.xyx.app" 
    android:id="@+id/drawer" 
    my:direction="topToBottom" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    my:handle="@+id/handle" 
    my:content="@+id/content" 
    android:layout_marginTop="100dp" 
    > 
    <include 
     android:id="@id/content" 
     layout="@layout/slider"/> 
    <ImageView 

     android:id="@id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="150px" 
     android:visibility="invisible" 

     android:src="@drawable/tooltiparea" /> 
</com.abc.xyx.customnotification.CustomDrawer> 


<RelativeLayout > 
this layout is used for holding child Activities views 
</RelativeLayout> 

生成訪問器方法來訪問slidingdrawer和parentLayout 。

現在你的活動中,要添加customSlidingBar應該從BaseActivity擴展了這種方式,您只需要滑動抽屜implemation

一次代碼希望它有助於

相關問題