2012-08-02 50 views
0

我是Android新手,我發現在這個鏈接http://code.google.com/p/android-page-curl/這個偉大的android頁面捲曲。 我的問題是,如何添加TextView? 我試過了,但當我嘗試時它總是強制關閉。 這是我在佈局xml中的代碼。如何在PageCurl中添加TextView?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <cv.tarie.pagecurl.PageCurlView 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:id="@+id/dcgpagecurlPageCurlView1"/> 

    <LinearLayout android:id="@+id/textlayout" 
     android:layout_width="fill_parent" android:layout_height="100dp" 
     android:layout_alignParentBottom="true" android:gravity="center" 
     android:background="#55000000" android:padding="5dp"> 

     <TextView android:id="@+id/dialog" android:layout_width="fill_parent" 
      android:layout_height="fill_parent" android:textSize="18dp" 
      android:textColor="#FFFFFF" /> 

    </LinearLayout> 
</RelativeLayout> 

我在PageCurlView中添加了這段代碼。

TextView tv = (TextView) findViewById(R.id.dialog); 
tv.setText("Hello!"); 

我的代碼有錯?

謝謝..

回答

0

你應該給一些更多的信息:你在哪裏添加代碼完全相同;什麼是logcat輸出,...

不管怎麼說,只要看看你的XML,一個簡單的問題給你自己: 爲什麼PageCurlView能夠找到TextView元素,而不是它的子元素?

您有:

  • RelativeLayout的
    • PageCurlView
    • 的LinearLayout
      • 的TextView

TextView只是RelativeLayout和LinearLayout的子項。 在PageCurlView中找不到TextView是不可能的。 FindViewById()只能下到ViewGroups的子節點中,而不是父節點。

我只是在想,你的問題可能是完全錯誤的。您是否試圖問「如何使TextChart之間切換PageCurl,而不是圖像?」。答案是:閱讀文檔,或只是主網站的第一頁。這不可能。它只能夠在圖像之間切換。

+0

好..這是我的錯,因爲我是新的Android ..:D 我只是嘗試使文本透明背景.. :) – Faras 2012-08-02 03:35:52

+0

@ user1561886:那麼,你的問題又是什麼?它甚至與PageCurlView有什麼關係? ;) – Oliver 2012-08-02 03:43:16

+0

嗯..是的,我錯了。我只需要使TextView具有黑色透明背景,並且我希望在頁面翻轉時文本發生變化。在再次提出問題之前,我需要現在做研究。 -.-「 順便說一句,謝謝你回答我的問題。:) – Faras 2012-08-02 04:03:26