0

代わりにxmlを介してこれを実装しようとしていますが、失敗した試行が多すぎます。2 つのボタンを作成して ViewId で呼び出してみましたが、カスタム ボタンであるため UI に表示されません。どうすればそれについて行くことができますか?

 LinearLayout ll = new LinearLayout(this);
            recButton = new CustomRecordButton(this);
            ll.addView(recButton,
                new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT,0));
            playButton = new CustomPlayButton(this);
            ll.addView(playButton, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,0));
            setContentView(ll);
4

1 に答える 1

1

ここに可能な方法があります

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto
android:layout_width="fill_parent"
android:layout_height="48dp"
android:orientation="horizontal" >

<package.to.my.CustomPlayButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

<package.to.my.CustomPlayButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

</LinearLayout>
于 2013-04-23T20:15:57.857 に答える