Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android:基本活动上的按钮点击事件_Android_Android Layout_Android Activity_Android Button_Android Framelayout - Fatal编程技术网

android:基本活动上的按钮点击事件

android:基本活动上的按钮点击事件,android,android-layout,android-activity,android-button,android-framelayout,Android,Android Layout,Android Activity,Android Button,Android Framelayout,我为我的应用程序中的所有活动和滑动菜单创建了一个相同布局的BaseActivity,我在BaseActivity布局中有一个按钮,我的问题是当我点击按钮时,什么事情都没有发生,日志上显示此消息: D/VelocityTracker﹕ Couldn't open '/dev/touch' (Permission denied) D/VelocityTracker﹕ tpd read x fail: Bad file number D/VelocityTracker﹕ tpd read y fail

我为我的应用程序中的所有活动和滑动菜单创建了一个相同布局的BaseActivity,我在BaseActivity布局中有一个按钮,我的问题是当我点击按钮时,什么事情都没有发生,日志上显示此消息:

D/VelocityTracker﹕ Couldn't open '/dev/touch' (Permission denied)
D/VelocityTracker﹕ tpd read x fail: Bad file number
D/VelocityTracker﹕ tpd read y fail: Bad file number
D/VelocityTracker﹕ Couldn't open '/dev/touch' (Permission denied)
D/VelocityTracker﹕ tpd read x fail: Bad file number
D/VelocityTracker﹕ tpd read y fail: Bad file number
I/View﹕ Touch down dispatch to android.widget.Button{424d3700 VFED..C. ........ 27,27-70,70 #7f070052 app:id/button_menu}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=27.332088, y[0]=3.7002335, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=182860652, downTime=182860652, deviceId=2, source=0x1002 }
I/View﹕ Touch up dispatch to android.widget.Button{424d3700 VFED..C. ...p.... 27,27-70,70 #7f070052 app:id/button_menu}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=24.136082, y[0]=3.7002335, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=182860725, downTime=182860652, deviceId=2, source=0x1002 }
这是我的基本活动布局:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- Put what you want as your normal screen in here, you can also choose for a linear layout or any other layout, whatever you prefer -->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFFFF"
        android:id="@+id/sub_layout"
       >
        <Button
            android:id="@+id/button_menu"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/menu"
            android:text="Ok" />

    </RelativeLayout>
</FrameLayout>
<!-- The navigation drawer -->
<RelativeLayout
    android:id="@+id/left_drawer"
    android:layout_width="250dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp">
</RelativeLayout>
我不明白是什么问题。 有人能帮我吗?
谢谢

您的xml中有一个问题。。 您正在关闭一个不存在的RelativeLayout

<FrameLayout>
--- <RelativeLayout>
-------- <Button></Button>
--- </RelativeLayout>
--- </RelativeLayout> *THIS*
</FrameLayout>

--- 
-------- 
--- 
---*本*

在相对布局中单击listview时出现一些错误,您必须添加一个名为android:genderantFocusability=“blocksDescendants”的属性来解决

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
..........
</RelativeLayout>

..........

希望这有帮助。

不,不是因为这个,这个错误发生在复制过去,我编辑了代码。你看到我的日志了吗?当我按下按钮时,这条信息显示在logcat上。@mahdi我看到了你的logcat,没有为我显示。该按钮切换抽屉布局,您的自定义日志已注册。我可能从你的LogCat中得到的想法是,设备本身是否有问题(比如被扎根之类的)。我建议您在另一个设备或模拟器中尝试,看看会发生什么。我在其他设备和模拟器上测试它,我从基本活动扩展了主要活动,基本活动的视图是否不能从其他活动访问?当我将按钮添加到导航抽屉时,它工作,但当我将此按钮添加到主要内容时,它不工作。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
..........
</RelativeLayout>