在視圖之間切換時出現錯誤。我在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