ImageButton 事件侦听器在 ScrollView 中不起作用 ->水平滚动视图
ImageButton
事件监听器不起作用。
这是我的代码(已更新):
XML:
<ScrollView ...>
<LinearLayout
android:orientation="vertical"
...
>
<HorizontalScrollView
...
>
<LinearLayout
android:orientation="horizontal"
...
>
<ImageButton
android:id="@+id/img_btn1"
/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
Java 代码:
public class Main extends Activity{
ImageButton imgBtn1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgBtn1 = (ImageButton) findViewById(R.id.img_btn1);
imgBtn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.w("onClick", "ImageButton Clicked");
}
});
}
}
此代码不起作用。感谢您的任何帮助。
ImageButton
event listener is not working.
Here's my code (updated):
XML:
<ScrollView ...>
<LinearLayout
android:orientation="vertical"
...
>
<HorizontalScrollView
...
>
<LinearLayout
android:orientation="horizontal"
...
>
<ImageButton
android:id="@+id/img_btn1"
/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
Java code:
public class Main extends Activity{
ImageButton imgBtn1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgBtn1 = (ImageButton) findViewById(R.id.img_btn1);
imgBtn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.w("onClick", "ImageButton Clicked");
}
});
}
}
This code is not working. Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:-----
Try this:-----
这在我这边工作得很好:
xml代码是:
This is working fine on mine side:
and xml code is: