UMA*_*MAR 2 android listactivity android-activity
同时显示进度条我想禁用触摸屏来限制Android手机中的其他功能.
任何人都可以指导我如何实现这一目标吗?
任何帮助都会被批评.
编辑
您可以通过实现ListView的自定义扩展来实现,您可以将其设置为要在XML文件中使用的列表.然后在CustomListView中,实现onTouchEvent方法,如果希望列表处理触摸,则只调用super.onTouchEvent.这就是我的意思:
在包含列表的布局文件中有这样的效果.
<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>
Run Code Online (Sandbox Code Playgroud)
然后有一个这样的自定义类:
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
此代码仅允许ListView处理触摸事件,如果它们位于屏幕的前100个像素中.显然,将if语句替换为更适合您的应用程序的语句.一旦你开始工作,也不要留在日志语句中,因为你会在每个手势后用数百条记录行自行发送垃圾邮件; 他们只是让他们明白发生了什么.
归档时间: |
|
查看次数: |
9267 次 |
最近记录: |