2012-10-06 24 views
1

首先要說的是我是初學者,現在我正在開發我的第一個「真正的」android應用程序(它將在Google Play上)。 我已經谷歌了很多關於這個「測驗」應用程序的Android和我不能得到好的信息,也沒有關於這個項目的例子(大多數的代碼/項目的例子是關於viewFlipper/TextSwitcher每次你改變屏幕 - 不是我想要的是)。我也嘗試在Stackoverflow中搜索,我得到的是一些沒有好的/有幫助的答案downvoted問題。android viewFlipper,TextSwitcher或其他什麼測驗應用程序?

所以會有我的應用程序測驗部分,我將有3個類型的問題:

  1. radiobutton答案
  2. checkboxlist答案
  3. 一個問題,一個問題一個問題與edittext答案

我的應用程序中將有大約50個問題,所以我有一個pla n創建3個不同的佈局

這些都是我的問題的?

  1. 你有任何聯繫/例子請分享(我已經試圖找到我自己):d
  2. 什麼是做到這一點的最好方法是什麼? (例如:如使用viewFlipper與佈局,或其他)
  3. 是否有可能使用viewFlipper生成3個不同類型的問題(3個佈局)?怎麼做?

謝謝:d

+1

檢查http://stackoverflow.com/questions/3060638/help-needed-for-android-quiz-app –

+0

感謝您的幫助:d 我已經檢查了這一個,但我不明白它:( –

+1

爲什麼Viewflipper?你想讓用戶滑過每個問題?更好地爲「下一個問題」:)按鈕。 – Ahmad

回答

2

您應該爲問題創建一個主佈局,其中TextView用於聲明,用於回答佈局的容器(如FrameLayout),以及之前的Button的。在容器中,您可以放置​​兩個視圖,一個ListView和一個EditText可編輯的答案。兩者的可見性都是無效的。

現在,一旦您看到了主佈局,就可以在同一個佈局中加載每個問題。您需要設置語句視圖的文本,如果您的問題有選項,您可以設置可見性,加載數據並將其設置爲單一/多項選擇。否則,如果你的問題有一個可編輯的答案,你可以設置EditText可見,(設置ListView visibilty不見了)。

這將比每個問題的膨脹單獨的佈局效率更高,也ListView完美處理任何數量的選項,可以是單/多項選擇,並允許滾動到任何選項獨立於屏幕大小。

佈局XML:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical"> 
    <TextView android:id="@+id/question__Statement" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
      /> 
    <FrameLayout android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
      > 
     <ListView android:id="@+id/question__options" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:visibility="gone" 
       /> 
     <EditText android:id="@+id/question__text" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:visibility="gone" 
       /> 
    </FrameLayout> 
    <LinearLayout android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
      > 
     <Button android:id="@+id/question__prev" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_alignParentLeft="true" 
       android:text="Previous" 
       /> 
     <Button android:id="@+id/question__next" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_alignParentRight="true" 
       android:text="Next" 
       /> 
    </LinearLayout> 

</LinearLayout> 
+0

感謝您的幫助:D 您有任何代碼示例嗎?對我有幫助 –

+0

非常感謝! :d –

1

我發現了一個偉大的示例應用程序爲您提供:

https://github.com/robhinds/AndroidChuckQuiz

它使用SQLite數據庫艱難的,你可能想閱讀起來,建立一個前應用程序「在其上」。

+0

感謝您的幫助:D –

相關問題