0

最初の方法:

<Button
    android:id="@+id/btnLogin"
    style="@style/btnStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnFacebook"
    android:layout_alignRight="@+id/btnFacebook"
    android:layout_below="@id/etPassword"
    android:layout_centerInParent="true"
    android:onClick="goHome"
    android:text="Login"/>

<Button
    android:id="@+id/btnFacebook"
    style="@style/btnFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/textOR"
    android:layout_marginTop="10dp"
    android:onClick="facebookSignUp"
    android:text="     Signup with Facebook     "/>


<Button
    android:id="@+id/btnGooglePlus"
    style="@style/btnGoogle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnFacebook"
    android:layout_alignRight="@+id/btnFacebook"
    android:layout_below="@id/btnFacebook"/>

第二の方法:

<Button
    android:id="@+id/btnLogin"
    style="@style/btnStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/etPassword"
    android:layout_centerInParent="true"
    android:onClick="goHome"
    android:text="Login"/>

<Button
    android:id="@id/btnFacebook"
    style="@style/btnFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/textOR"
    android:layout_marginTop="10dp"
    android:onClick="facebookSignUp"
    android:text="     Signup with Facebook     "/>


<Button
    android:id="@+id/btnGooglePlus"
    style="@style/btnGoogle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/btnFacebook"/>

第三の方法:

<Button
    android:id="@+id/btnLogin"
    style="@style/btnStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/etPassword"
    android:layout_centerInParent="true"
    android:onClick="goHome"
    android:text="Login"/>

<Button
    android:id="@+id/btnFacebook"
    style="@style/btnFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/textOR"
    android:layout_marginTop="10dp"
    android:onClick="facebookSignUp"
    android:text="     Signup with Facebook     "/>


<Button
    android:id="@+id/btnGooglePlus"
    style="@style/btnGoogle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/btnFacebook"
    android:layout_alignRight="@id/btnFacebook"
    android:layout_below="@id/btnFacebook"/>

2 つの質問:

  1. 初期化の 3 つの方法すべての出力

btnフェイスブック

と同じ。どのように?

  1. 出力が同じなので、XML Parser のコンパイル結果も同じです。では、リソースの初期化はどのように正確に行われ、どのように ViewTree にアタッチされるのでしょうか?

説明付きの公式ドキュメントは大歓迎です。前もって感謝します :)

4

1 に答える 1

1

ここから

順序に違いはありません。

ビューは同じですが、btnFacebook が btnLogin の前に宣言されていないため、3 番目の方法は機能しません。したがって、コンパイルエラーが表示されます。3番目の方法は、わずかな変更後に機能します。そのリンクを参照してください。詳細について

于 2016-08-12T05:23:36.317 に答える