sony smartwatch 2 click event not being raised

你。 提交于 2019-12-12 00:26:36

问题


I'm guessing this is just me doing something a bit dumb. I have a load of TextViews in my layout file which I'm using to create a number pad. They are 0-9 like this:

<TextView android:id="@+id/pad_number_7" android:text="@string/pad_number_text_7" style="@style/pad_button" />

The pad_button style includes:

<item name="android:clickable">true</item>

Then in my ControlExtension class' constructor I am calling a method called wireUpButtons() with code like this:

mLayout = parseLayout(((LayoutInflater)mContext.getSystemService("layout_inflater")).inflate(R.layout.pad_layout, null));
if (mLayout != null)
{
    Log.d("DK", "Adding event for button 7");
    ControlView controlview = mLayout.findViewById(R.id.pad_number_7);
    controlview.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(){
            Log.d("DK", "Button 7 clicked");
            sendResult("7");
        }
    });
}

And my onResume shows the layout:

@Override
public void onResume() {
    showLayout(R.layout.pad_layout, null);
}

But the log entry is never created and the call to sendResult doesn't happen. Does anyone know why my click events aren't firing? The call to wire up the event does happen, as the log first log entry is shown, and I've tried moving the call to wireUpButtons() to the onResume function (both before and after the showLayout call) with no change.


回答1:


OK I realised I was missing the onObjectClick method to pass the click event up to the handler:

@Override
public void onObjectClick(final ControlObjectClickEvent event) {
    if (event.getLayoutReference() != -1) {
        mLayout.onClick(event.getLayoutReference());
    }
}

After adding this method it all works now



来源:https://stackoverflow.com/questions/21023525/sony-smartwatch-2-click-event-not-being-raised

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!