按钮单击不工作android

时间:2016-02-02 07:45:33

标签: android button

我在活动中有多个按钮,但问题是在len(df)=7期间点击了一些按钮而某些按钮未被点击。

这是我项目的重要部分,我非常渴望这样做。但我没有成功。所以请帮帮我。我已经检查过其他网站的多个解决方案,但没有工作。

这是myactivity代码部分。

In [475]: %timeit one(df)
The slowest run took 11.16 times longer than the fastest. This could mean that an intermediate result is being cached 
1000 loops, best of 3: 379 µs per loop

In [476]: %timeit two(df1)
The slowest run took 11.93 times longer than the fastest. This could mean that an intermediate result is being cached 
1000 loops, best of 3: 336 µs per loop

In [477]: %timeit three(df2)
1000 loops, best of 3: 398 µs per loop

In [478]: %timeit four(df3)
The slowest run took 19.07 times longer than the fastest. This could mean that an intermediate result is being cached 
10000 loops, best of 3: 159 µs per loop

In [479]: %timeit five(df4)
The slowest run took 4.89 times longer than the fastest. This could mean that an intermediate result is being cached 
1000 loops, best of 3: 1.26 ms per loop

1 个答案:

答案 0 :(得分:1)

<强>建议

Bad Approach :使用已弃用 ActionBarActivity。使用AppCompatActivity

只需在XML中设置onClick,就会容易得多。

android:onClick="Button_Click"

然后加入你的班级,

public void Button_Click(View v) {
    // Add your Code
}

<强>最后

 <Button
    android:id="@+id/btn_student_parents"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginBottom="5dp"
    android:background="#4385F5"
    android:textColor="#ffffff"
    android:text="Parents/Students Locator"
    android:onClick="Button_Click"
    android:layout_above="@+id/btn_howtouse" />