你好。我已经直接复制并粘贴了这段代码,但出现了投射错误:无法从视图投射到 viewflipper。
public class ViewFlipper extends Activity implements OnClickListener
{
Button next;
Button previous;
ViewFlipper vf;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
vf = (ViewFlipper) findViewById(R.id.ViewFlipper01);
setContentView(R.layout.main);
//vf = (ViewFlipper) findViewById(R.id.ViewFlipper01);
next = (Button) findViewById(R.id.Button01);
previous = (Button) findViewById(R.id.Button02);
next.setOnClickListener(this);
previous.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v == next) {
vf.showNext();
}
if (v == previous) {
vf.showPrevious();
}
}
}