Hardware Reference
In-Depth Information
android:layout_toLeftOf="@+id/clear"
android:onClick="SyncData"
android:text="@string/sync" />
</RelativeLayout>
Listing 8-5 is the strings.xml file and defines the new application name, a hint for the Edit text box, and the
name of the two buttons. As stated in Chapter 4, putting the information in the strings.xml file saves you from having
to go to every instance that will be used to change a name. When this application is loaded on the Android device,
it will have a different name than that of the ADK monitor, but will still respond to the same accessory name declared
in the Arduino sketch. Sharing the same information is not a problem if the default program option on the autorun
pop-up menu is not selected. The Android device will give a series of options if there are multiple programs that use
the same accessory. If the multiple options are undesirable, change the declaration to a new accessory name in the
Arduino sketch, and change the accessory_filter.xml file in the Android project to reflect the changes.
Listing 8-5. strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ADK Sensor Network</string>
<string name="hint">Data from Arduino board will be displayed here</string>
<string name="sync">Sync</string>
<string name="clear">Clear</string>
</resources>
New objects for the chart engine need to be imported for you to use the graphing capabilities in the application.
Listing 8-6 shows the new imports needed for the chart that will be used. ChartFactory and GraphicalView make up
the main core of the chart engine. There is a data class that contains the data in a series for the graph using Cartesian
x- and y- coordinates for the point's position. XYMultipleSeriesDataset is used for a class that will contain all the
series data that will need to be displayed on the screen. XYSeriesRenderer and XYMultipleSeriesRenderer are
needed to get the data rendered properly. The import android.graphics.Color is used to get classes that predefine
colors such as red, green, and blue to make color use a bit easier. The import android.widget.LinearLayout will
allow the blank layout to be accessible for adding the graph to the layout space defined in main.xml . Add the import in
Listing 8-6 to the beginning of the ADK framework from Chapter 4.
Listing 8-6. New Imports for Using the AChartEngine Library
import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;
import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.View;
import android.widget.Button;
import android.widget.EditText;
 
Search WWH ::




Custom Search