PDA

View Full Version : مشکل دستور if



Pam.goudarzi
پنج شنبه 02 مرداد 1393, 13:28 عصر
سلام! من چند تا رادیوباتن دارم که اگه کاربر روی یکی از اونا کلیک کنه و بعدش هم روی ایمج ویو بزنه، یک مدیا پلیر شروع به کار میکنه، و عکس ایمج ویو رو عوض می کنه. حالا من هر کاری کردم با کد زیر هیچ کدوم از این اتفاقات نمی افتن.! چی کار کنم؟
final MediaPlayer mm = MediaPlayer.create(MainActivity.this, R.raw.pitch14); RadioButton forteen = (RadioButton) findViewById(R.id.radioButton1);
RadioButton sixteen = (RadioButton) findViewById(R.id.radioButton2);
RadioButton twenty = (RadioButton) findViewById(R.id.radioButton3);
final ImageView img1 = (ImageView) findViewById(R.id.imageView1);

if (forteen.isChecked()== true) {
img1.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
mm.start();
img1.setBackgroundResource(R.drawable.anti_on);
}
});

ali-star
پنج شنبه 02 مرداد 1393, 13:37 عصر
== true رو پاک کن درست میشه.

Programmatore
پنج شنبه 02 مرداد 1393, 13:41 عصر
این شرطی که گذاشتی کلا اشتباهه :) شرط رو بیار داخل متد onClick

Pam.goudarzi
پنج شنبه 02 مرداد 1393, 15:45 عصر
این شرطی که گذاشتی کلا اشتباهه :) شرط رو بیار داخل متد onClick
خیلی ممنون! درست شد! ولی هنوز با
setBackgroundresource عکسه عوض نمی شه!! می دونین مشکل چیه؟