2012-03-01 72 views
2

在我的應用程序有一個自定義通知,具有以下佈局。我的問題是,選框不起作用。 PLZ幫助我。在此先感謝Android的通知跑馬燈不工作

> <?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/notification_layout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="10dp" > 

    <ImageView 
     android:id="@+id/notification_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_marginRight="10dp" 
     android:background="@drawable/icon" /> 

    <TextView 
     android:id="@+id/notification_title" 
     style="@style/NotificationTitle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/notification_image" 
     android:text="asaadsadad" /> 

    <TextView 
     android:id="@+id/notification_message" 
     style="@style/NotificationText" 
     android:layout_width="wrap_content" 
     android:ellipsize="marquee" 
     android:lines="1" 
     android:marqueeRepeatLimit="marquee_forever" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/notification_title" 
     android:layout_toRightOf="@+id/notification_image" 
     android:text="@string/four_day_delay_msg" 
     android:focusable="true" /> 

</RelativeLayout> 

可以在通知中添加滾動?

+0

自定義通知?你的意思是一個自定義的烤麪包? – Rawr 2012-03-01 08:47:09

+0

不,我的意思是狀態欄通知 – jibysthomas 2012-03-01 12:36:44

+0

尋找這個給我多一點時間。 – Rawr 2012-03-01 19:43:35

回答

6

嗯,我已經花了相當多的時間來研究這一點,我認爲它是安全的,說有一些主要障礙,以實現這一目標需要克服。值得注意的是,在他們的自定義通知中,有一些Google Apps使用Marquee的例子,但是它們在HoneyComb Android 4.0版本中,所以他們可能會解決我即將解決的問題。 另外,我還沒有看到在谷​​歌應用中使用谷歌應用框架實現的選框,它應該是長歌名或藝術家的選擇框。

我喜歡編號列表...

  1. 帶字幕的問題。這是一個挑剔的設置,你不僅需要設置省略號來標記,你必須確保它所包含的視圖獲得焦點,否則它將永遠不會被選中。自然,我第一次試圖在通知創建後嘗試着重於textview。 Android不喜歡這樣,到了#2。
  2. 然後我繼續研究自動滾動字幕TextViews。我以爲我這次有過,不幸的是沒有。一些真正聰明的人決定他們不喜歡選取框的限制,所以他們創建了一個可以自動自動聚焦的自定義組件。所以選取框將始終運作。但是當我將它添加到自定義通知Android時再次說不。我猜自定義通知不喜歡自定義組件,我甚至嘗試創建一個自定義的RelativeLayout,以在onFinishInflate()被調用時專注於textview。
  3. 有這麼多的研究,你能做到,那我就放棄了。查看如何在自定義通知中使用自定義組件。我看,至少15分鐘,沒有運氣。或者查看如何將項目聚焦在自定義通知中,似乎更加奇怪。我的兩個搜索都沒有找到結果,但沒有太多有關這種事情的StackOverflow問題。在這裏發佈一個新問題可能會產生一些運氣。

資源...

定製組件 - 自動滾動字幕的TextView - http://androidbears.stellarpc.net/?p=185

自定義組件 - 相對佈局onFinishInflate() - Android : how to create custom component - http://www.devdaily.com/java/jwarehouse/android/core/java/android/widget/TwoLineListItem.java.shtml

谷歌應用程序與例如跑馬燈在自定義通知(TextView的標題是:notification_title) - http://developer.android.com/resources/samples/HoneycombGallery/res/layout/notification.html