有几个页面,第一个页面全是layout形式的Button,启动进入第一个页面时点击Button是没有反应的,当滑动页面再回到第一页面,点击就有效了!很纳闷,就将点击后要执行的代码放到OnPageChangeListener里面,这样一来运行不起来,这是什么缘故,有什么解决的方法?android OnPageChangeListener

解决方案 »

  1.   

    第一个页面时点击Button是没有反应的??为什么?获取不到焦点吗
      

  2.   

    第一个页面时点击Button是没有反应的??为什么?获取不到焦点吗
    焦点是有获取到的,点击后(Selector)有变化,就是进不了下一步,我用是监听整个layout来作按钮的,设置了Selector,当时点击没有变化,就在layout里添加了android:clickable="true",点击就有变化但点击无效,只有切换到第二页面再返回点击才有效
      

  3.   

    第一个页面时点击Button是没有反应的??为什么?获取不到焦点吗
    焦点是有获取到的,点击后(Selector)有变化,就是进不了下一步,我用是监听整个layout来作按钮的,设置了Selector,当时点击没有变化,就在layout里添加了android:clickable="true",点击就有变化但点击无效,只有切换到第二页面再返回点击才有效
    你是点击Button然后里面的代码不执行吗?
      

  4.   

    第一个页面时点击Button是没有反应的??为什么?获取不到焦点吗
    焦点是有获取到的,点击后(Selector)有变化,就是进不了下一步,我用是监听整个layout来作按钮的,设置了Selector,当时点击没有变化,就在layout里添加了android:clickable="true",点击就有变化但点击无效,只有切换到第二页面再返回点击才有效
    你是点击Button然后里面的代码不执行吗?
    对,只有切换到第二页面再返回,点击才能执行!代码没有出错,也能运行!
      

  5.   

    第一个页面时点击Button是没有反应的??为什么?获取不到焦点吗
    焦点是有获取到的,点击后(Selector)有变化,就是进不了下一步,我用是监听整个layout来作按钮的,设置了Selector,当时点击没有变化,就在layout里添加了android:clickable="true",点击就有变化但点击无效,只有切换到第二页面再返回点击才有效
    你是点击Button然后里面的代码不执行吗?
    对,只有切换到第二页面再返回,点击才能执行!代码没有出错,也能运行!
    不清楚....
    你试试这样写呢
        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="你的方法"
            android:text="button" />
      

  6.   

    第一个页面时点击Button是没有反应的??为什么?获取不到焦点吗
    焦点是有获取到的,点击后(Selector)有变化,就是进不了下一步,我用是监听整个layout来作按钮的,设置了Selector,当时点击没有变化,就在layout里添加了android:clickable="true",点击就有变化但点击无效,只有切换到第二页面再返回点击才有效
    你是点击Button然后里面的代码不执行吗?
    对,只有切换到第二页面再返回,点击才能执行!代码没有出错,也能运行!
    不清楚....
    你试试这样写呢
        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="你的方法"
            android:text="button" /><LinearLayout
                    android:id="@+id/setting"
                    android:layout_width="108dp"
                    android:background="@drawable/layout_selector"
                    android:layout_height="108dp"
                    android:clickable="true"
                    android:layout_marginLeft="5dp"
                    android:orientation="vertical" >                <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:layout_marginTop="30dp"
                        android:background="@drawable/setting" />                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:text="@string/setting" />
                </LinearLayout>
      

  7.   

    放到PagerAdapter的instantiateItem进行初始化即可