2012-02-14 12 views
1

に応じて、これまでのところ、私はそこにサムネイルの選択は、あるサムネイルをクリックしたら、それは以下のXMLに設定されているSurfaceViewCamera Activityを開きActivityを持っています前に選択したサムネイルに応じてSurafceViewを変更できる方法が必要ですActivityサムネイルをbuttonsとして設定しました。私は各ボタンにSurfaceViewで使用するイメージ名と同じIDを与えていますので、ボタンIDを取って下のRelativeLayoutの背景を変更する方法があります。変更SurfaceViewイメージはサムネイル

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/overlay" 
android:gravity="bottom" 
android:orientation="vertical" > 

<Button 
    android:id="@+id/takepicture" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_margin="10px" 
    android:layout_marginBottom="10dp" 
    android:background="@drawable/capture" /> 

</RelativeLayout> 

のJava:

View viewControl = controlInflater.inflate(R.layout.control, null); 
    LayoutParams layoutParamsControl 
     = new LayoutParams(LayoutParams.FILL_PARENT, 
     LayoutParams.FILL_PARENT); 
    this.addContentView(viewControl, layoutParamsControl); 
+0

新しいアクティビティを開始したのですか、新しいレイアウトを設定するだけですか? –

+0

Matt、カメラアクティビティのxmlレイアウトを追加するのを忘れました。あなたがボタンのIDで何をしようとしているかははっきりしていません。 –

答えて

1

カメラのアクティビティを起動する、意思のエキストラがそうのようなバンドルにしたい背景のIDを置く:第二の活動で

intent.putExtra("backgroundId", backgroundId); 
startActivity(intent); 

インテントからバックグラウンドIDを取得し、ルートビューのバックグラウンドに割り当てます。

@Override 
public void onCreate(Bundle bundle) { 
    ... 
    int backgroundId = getIntent().getIntExtra("backgroundId", 0); 
    viewControl.setBackgroundResouce(backgroundId); 
    ... 
} 
関連する問題