索尼智能手表2 click事件没有被引发 [英] sony smartwatch 2 click event not being raised

查看:180
本文介绍了索尼智能手表2 click事件没有被引发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我猜这只是我做的事情有点哑。我在我的布局文件TextViews这我使用创造了数字键盘的负载。他们是0-9这样的:

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" />

该pad_button风格包括:

The pad_button style includes:

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

然后在我的ControlExtension类的构造函数,我调用一个方法叫做wireUpButtons()与code是这样的:

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");
        }
    });
}

和我onResume显示的布局:

And my onResume shows the layout:

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

但从未创建日志条目,并调用sendResult不会发生。有谁知道为什么我的点击事件不被解雇?要连接事件的电话确实发生,因为日志第一个日志条目显示,我已经试过没有变化(前和showLayout呼叫后)移动调用wireUpButtons()到onResume功能。

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.

推荐答案

OK我意识到我错过了onObjectClick方法传递click事件到处理程序:

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

这篇关于索尼智能手表2 click事件没有被引发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆