将收信人编辑区放到FrameLayout中,给FrameLayout再加一个LinearLayout孩子。
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<LinearLayout
android:id="@+id/layout_person"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:clickable="true"
android:background="@color/white"
android:visibility="invisible">
<TextView
android:id="@+id/personName"
android:textSize="14dip"
android:textColor="@color/black"
android:clickable="true"
android:singleLine="true"
android:ellipsize="middle"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/addPerson"
android:src="@drawable/ic_add_recipient"
android:layout_marginLeft="20dip"
android:layout_width="30dip"
android:layout_height="30dip"
android:scaleType="centerInside"/>
</LinearLayout>
<!-- 收件人编辑区 -->
<com.txrj.sms.component.ScrollviewSupportMaxHeight
android:id="@+id/recipients_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_recipient_input"
android:scrollbars="vertical" >
<com.txrj.sms.component.RecipientEditor
android:id="@+id/recipients_editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000" />
</com.txrj.sms.component.ScrollviewSupportMaxHeight>
</FrameLayout>
点击R.id.addPerson按钮时,跳转到联系人列表中。
findViewById(R.id.addPerson).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent it = new Intent(mContext, ContactListActivity.class);
it.setAction(TxrjConstant.ACTION_ADD_RECIPIENT);
it.putParcelableArrayListExtra(TxrjConstant.EXTRA_RECIPIENT_LIST, mRecipients);
startActivityForResult(it, TxrjConstant.REQUEST_ADD_CONTACT);
}
});
给layoutPerson,mPersonName添加ClickListener。
layoutPerson.setOnClickListener(personClickListener);
mPersonName.setOnClickListener(personClickListener);
显示收信人编辑区,并让收信人编辑框获取焦点。
View.OnClickListener personClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
layoutPerson.setVisibility(View.INVISIBLE);
layoutEditRecipient.setVisibility(View.VISIBLE);
mRecipientInput.requestFocus();
}
};