0

ここで立ち往生しました。複数のxmlファイルに表示する方法がわかりません。button1.xml、button2.xml、およびbutton3.xmlがあります。これらのビューをアクティビティで動的に切り替えられるようにしたいと考えています。

> <LinearLayout
> xmlns:android="http://schemas.android.com/apk/res/android"
>     android:orientation="vertical"
>     android:layout_width="match_parent"
>     android:layout_height="match_parent" >
>       <com.apps.example.TouchImageView
>       android:id="@+id/snoop"
>       android:layout_width="match_parent"
>       android:src="@drawable/keutamaandua"
>       android:layout_height="match_parent" />

javaファイル

public class TouchImageViewActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.button1);
        TouchImageView img = (TouchImageView) findViewById(R.id.snoop);
        img.setImageResource(R.drawable.keutamaandua);
        img.setMaxZoom(4f);
4

1 に答える 1

0

setVisibility()あなたの問題を解決するはずです。view.setVisibility(View.VISIBLE)およびを使用view.setVisibility(View.GONE)して、アクティビティ レイアウトでビューを動的に表示および非表示にします。または、複数の xml ファイルがあり、それらを同じアクティビティで表示したい場合はsetContentView(id)、適切な ID で再度呼び出します。

于 2012-12-20T19:19:23.450 に答える