1

QuickContactBadgesを使用して連絡先の写真とポップアップアクションペインを表示するアプリがあります。

私のレイアウトでは、連絡先の名前を表示するTextView下もあります。QuickContactBadge

QuickContactBadge現在、連絡先の写真(適切なもの)をクリック/タッチしたときにのみ、実際のクイックアクションペインが表示されます。名前の表示をクリックしたときにアクションペインも表示されるようにしたいと思いますTextView

TextViewのクリックイベントをキャッチし、それを使用してQuickContactBadgeのクリックをトリガーし、それによってアクションペインを表示する方法はありますか?

質問に本当に当てはまるかどうかはわかりませんが、これが私のレイアウトのXMLです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="top|center_horizontal"
    android:orientation="vertical" >

    <QuickContactBadge
        android:id="@+id/ContactBadge"
        android:layout_width="48dp"
        android:layout_height="48dp" >
    </QuickContactBadge>

    <TextView
        android:id="@+id/ContactName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:ellipsize="end"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:freezesText="true"
        android:gravity="top|center_horizontal"
        android:lines="2"
        android:text="@string/val_DefaultString" >
    </TextView>

</LinearLayout>
4

1 に答える 1

2

TextViewをバインドするとき、私は次のことを行いました。

TextView tv = (TextView) v.findViewById(R.id.ContactName);
tv.setText(cnm);
tv.setOnClickListener(this);

その後、私のアクティビティはを実装しOnClickListenerます。次に、OnClickオーバーライドで、次の手順を実行します。

@Override
public void onClick(View v) {
    switch(v.getId()) {
        case R.id.ContactName:
            TextView tv = (TextView) v;
            LinearLayout ll = (LinearLayout) tv.getParent();
            QuickContactBadge qb = (QuickContactBadge) ll.findViewById(R.id.ContactBadge);
            qb.performClick();

            break;
    }
}

ここで重要なのは次の行ですqb.performClick();

于 2012-06-02T05:21:52.887 に答える