在视图之间切换时出现错误。我在xml的每个图像按钮上都有android:onClick="onClick"
。下面是代码使用ImageButton切换多个视图
selfHelp = (ImageButton)findViewById(R.id.selfhelpButton);
services = (ImageButton)findViewById(R.id.services);
messages = (ImageButton)findViewById(R.id.mailButton);
about = (ImageButton)findViewById(R.id.aboutButton);
more = (ImageButton)findViewById(R.id.moreButton);
selfHelp.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), SelfHelp.class);
startActivity(myIntent);
}
});
Services.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Services.class);
startActivity(myIntent);
}
});
messages.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Messages.class);
startActivity(myIntent);
}
});
about.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), About.class);
startActivity(myIntent);
}
});
more.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), More.class);
startActivity(myIntent);
}
});
我有另一页上这个工作只有一个按钮,但图像按钮不起作用。任何帮助将是巨大的
请发表您的错误和/或堆栈跟踪 – styler1972