I'd like to create a list of buttons that depend on device supported parameters ; for example, if the device's camera supports setting white balance and antibanding, then 2 corresponding buttons are displayed to allow the user to changes these settings; but if I run the same App on a device that supports only setting for white balance, then only one button is displayed.
I know how to create a list of buttons in the layout .xml file and I know how to test for supported parameters in the activity .java file, but I don't seem to find a way how to link these together.
Any help is greatly appreciated.
FWIW, here are the relevant pieces of my code so far
activity .java file
package com.MyProject;
import java.util.List;
import android.app.Activity;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class CameraSettingActivity extends Activity {
private static final String TAG = "CameraSettingActivity";
private Object mCameraView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.camera_setting);
Camera mCamera = Camera.open();
/* View mCameraView;*/
Camera.Parameters params = mCamera.getParameters();
// Get supported white balance modes
List<String> white_balance = params.getSupportedWhiteBalance();
if (white_balance!=null) {
String mString = white_balance.get(0);
Log.i(TAG, "CAMERA WHITE BALANCE : (" + mString + ")");
}
// Get supported antibanding modes
List<String> antibanding = params.getSupportedAntibanding();
if (antibanding!=null) {
String mString = antibanding.get(0);
Log.i(TAG, "CAMERA ANTIBANDING : (" + mString + ")");
}
mCamera.setParameters(params);
mCamera.release();
}
}
layout .xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:background="@color/green_background"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="@string/under_construction"
/>
<Button
android:id="@+id/white_balance_button"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="@string/white_balance"
/>
<Button
android:id="@+id/antibanding_button"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="@string/antibanding"
/>
</LinearLayout>