开发者

Adding background resource in Java, with if/else or switch.

开发者 https://www.devze.com 2023-03-23 09:41 出处:网络
I need help adding a background on android slider.java, so I want to have a background and to change it like this:

I need help adding a background on android slider.java, so I want to have a background and to change it like this:

getBackground (开发者_JAVA技巧 R.drawable_slider_bg);
if leftslider = PRESSED (getBackground = (R.drawable.slider_left_bg));
if rightslider = PRESSED (getBackground = (R.drawable.slider_right_bg));

Can someone help please?


// on slider.java

setBackgroundDrawable( R.drawable_slider_bg);

leftSlider.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
    setBackgroundDrawable(R.drawable.slider_left_bg);
  }
};

rightSlider.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
    setBackgroundDrawable(R.drawable.slider_right_bg);
  }
};
0

精彩评论

暂无评论...
验证码 换一张
取 消