如何禁用触摸屏的Andr​​oid手机? [英] how to disable Touch Screen in Android Phone?

查看:125
本文介绍了如何禁用触摸屏的Andr​​oid手机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同时显示进度条,我想禁用触摸屏来限制Android手机的其他功能。

while showing progress bar i want to disable touch screen to restrict other functionalities in android phone.

任何一个可以指导我如何实现这一目标?

can any one guide me how to achieve this?

任何帮助将appricated。

any help would be appricated.

推荐答案

修改

您可以通过实现ListView控件的你设置为列表,在XML文件中使用自定义的扩展做。然后在你的CustomListView,实现的onTouchEvent方法,只叫super.onTouchEvent如果你想触摸到的名单进行处理。这就是我的意思是:

You can do it by implementing a custom extension of ListView which you set as the list to use in your XML file. Then in your CustomListView, implement the onTouchEvent method and only call super.onTouchEvent if you want the touch to be processed by the list. Here's what I mean:

有话这种影响在包含列表中的布局文件。

Have something to this effect in the layout file that contains your list.

<com.steve.CustomListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/start_menu_background"
    android:cacheColorHint="#00000000"
    android:id="@android:id/list">
</com.steve.CustomListView>

然后有一个这样的自定义类:

Then have a custom class like this:

public class CustomListView extends ListView {
    Context mContext;

    public CustomListView (Context context, AttributeSet attrs){
        super(context, attrs);
        mContext = context;
    }

    public boolean onTouchEvent(MotionEvent event){
        if (event.getRawY() < 100){
            Log.d("Your tag", "Allowing the touch to go to the list.");
            super.onTouchEvent(event);
            return true;
        } else {
            Log.d("Your tag", "Not allowing the touch to go to the list.");
            return true;
        }
    }
}

这code将只允许触摸事件得到由ListView的处理,如果他们在屏幕上方100像素。显然,替换if语句的东西更适合您的应用程序。也不要在日志报表离开一旦你得到它的工作,因为你将自己的垃圾邮件数以百计的每个手势后,记录线;他们只有自己做出明显发生了什么。

This code will only allow touch events to get processed by the ListView if they're in the top 100 pixels of the screen. Obviously, replace that if statement with something more appropriate for your application. Also don't leave in the Log statements once you've got it to work since you'll spam yourself with hundreds of logging lines after each gesture; they're only their to make obvious what is happening.

这篇关于如何禁用触摸屏的Andr​​oid手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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