2013-03-07 63 views
0

我正在開發一款Android應用程序,它可以記錄來自麥克風的數據並進行實時音高檢測並將音高值繪製爲圖形。到目前爲止,我已經完成了實時音高檢測。現在我想以圖形動態繪製這些值。所以我的應用程序的屏幕應該有2個片段。一個有Record和Stop按鈕,我想在另一個片段中顯示我的圖形。我已經理解如何使用AChartEngine實時繪製一個graoh。我也瞭解使用片段的基本知識。所以我的問題是,如何將所有這些連接在一起?即,我想運行我的音高檢測活動,並在點擊錄製按鈕時動態顯示圖形,並在點擊停止按鈕時停止整個事件。有沒有任何示例代碼在一個片段中點擊按鈕時在另一個片段上顯示繪圖圖形? 謝謝!使用AChartEngine在一個片段上點擊另一個片段中的按鈕來繪製動態圖表?

回答

0

這只是我的想法。你可以做的是,建立兩個片段,創建將用於顯示和供應數據的片段(如果fragment.setArgs()不足以滿足你的需求)一些方法

想象一下,你在你的SecondFragment一樣,方法其你打電話的時候你打的停止,你從後面堆帶來的第二個片段:

public void showRecordedData(SomeDataModel data){ 
    this.mFragmentData = data; 
    ///show the data on the chart view of the second fragment 
} 

確保SecondFragment不是null可見。

希望這是有道理的。

0

使用滾動型像:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ScrollViewChartContainer" android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <LinearLayout android:id="@+id/main" android:layout_width="fill_parent" android:layout_height="match_parent"> 
     <LinearLayout android:id="@+id/chart1" android:layout_width="fill_parent" android:layout_height="match_parent" android:background="@android:color/transparent" android:orientation="horizontal" /> 
     <LinearLayout android:id="@+id/chart2" android:layout_width="fill_parent" android:layout_height="match_parent" android:background="@android:color/transparent" android:orientation="horizontal" /> 
    </LinearLayout> 
</ScrollView> 

我沒有測試過這樣的佈局,但它應該工作。

相關問題