简体   繁体   English

用于Horizo​​nalScrolView的View.OnFocusChangeListener?

[英]View.OnFocusChangeListener for HorizonalScrolView?

Does any one have idea how View.OnFocusChangeListener work for HorizontalScrollView ? 有谁知道View.OnFocusChangeListener如何为HorizontalScrollView工作吗?
I want basicaaly focus event for it's child view ? 我想要基本焦点事件的子视图吗?

any one have idea about it? 有人对此有想法吗?

I have tried with your problem with following way : 我已经尝试通过以下方式解决您的问题:

view1 = (LinearLayout) findViewById(R.id.linear1);

view1.setOnFocusChangeListener(new OnFocusChangeListener() {
            public void onFocusChange(View v, boolean hasFocus) {
                    if(hasFocus){
                        Toast.makeText(getApplicationContext(), "view1 Got Focus", Toast.LENGTH_SHORT).show();
                    }
                    else{
                        Toast.makeText(getApplicationContext(), "view1 Lost Focus", Toast.LENGTH_SHORT).show();
                    }
            }
        });

But this is not firing anything, means linear layout is not able to get and lost focus. 但这并没有触发任何东西,这意味着线性布局无法获得和失去焦点。

So, I tried with setOnClickListener listener in this way : 因此,我以这种方式尝试了setOnClickListener侦听器:

view1 = (LinearLayout) findViewById(R.id.linear1);

view1.setOnClickListener(new OnClickListener() {            
            @Override
            public void onClick(View v) {
                Toast.makeText(getApplicationContext(), "view1 Got Focus", Toast.LENGTH_SHORT).show();
            }
        });

And it works fine. 而且效果很好。

So, it may be helpful to you to set your logic from your linear layout's setOnClickListener event. 因此,从线性布局的setOnClickListener事件设置逻辑可能对您有所帮助。

Let me know if you find any confusion or need more help from me. 如果您有任何困惑或需要我更多的帮助,请告诉我。

Hope it helps you. 希望对您有帮助。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM