splitwise / TokenAutoComplete

Gmail style MultiAutoCompleteTextView for Android
Apache License 2.0
1.3k stars 383 forks source link

How do i remove a token based on click of a delete button inside my custom view? #252

Closed VeneetReddy closed 8 years ago

VeneetReddy commented 8 years ago

My custom view of token is like this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/token_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/token_left_padding"
    android:paddingRight="0dp"
    android:background="@drawable/contact_token_background">

    <TextView
        android:id="@+id/token_textview"
        android:layout_centerVertical="true"
        android:textColor="@color/black"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>

    <Button
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/token_textview"
        android:id="@+id/token_delete_button"
        android:layout_height="@dimen/icon_size"
        android:layout_width="@dimen/icon_size"
        android:background="@drawable/round_delete_button"
        android:layout_marginLeft="@dimen/icon_margin"
        android:layout_marginRight="@dimen/icon_margin"/>

</RelativeLayout>

How do I delete the token when the token_delete_button is clicked?

I tried adding a on OnClickListener to the button in the getViewForObject. It is not getting invoked.

Any suggestions?

mgod commented 8 years ago

I'd guess this is theoretically possible, but it would involved you grabbing the click event and manually calculating view positions based on the text layout to figure out if a view was hit. I note you've seen #250 which has my best guess on this.

akashk1992 commented 7 years ago

@VeneetReddy @mgod have you got any idea regarding this problem?

mgod commented 7 years ago

@akashk1992 I would use the Select style where one click selects a token and a second click deletes it, along with implementing a selected layout for my tokens. As I noted, #250 has my best suggestion for implementing this, and I would personally just not use this library and roll my own layout and completion if you need this.

Making this possible in general is not something I consider in-scope for this library.