رفتن به مطلب
انجمن اندروید ایران | آموزش برنامه نویسی اندروید و موبایل
  • android.png.1fab383bc8500cd93127cebc65b1dcab.png

پست های پیشنهاد شده

سلام

جون هر کی دوست دارین کمکم کنید 

من می خوام به بر نامه بگم که اگر بکگراند یک باتن این بود این کارو بکن بگید کد شو بگید لطفا من هر چی تلاش کردم نتونستم پیدا کنم

اسم عکس بک گراندم but1 هست

اسم باتنم b1 هست

لینک ارسال
به اشتراک گذاری در سایت های دیگر

اینکار ایده درستی نمیباشد بهتره بجای اینکه یک مقدار عددی یا رشته ای قرار دهید تا شرط را بررسی کنید

لینک ارسال
به اشتراک گذاری در سایت های دیگر

داداش باید یه متغیر عددی تعریف کنی بعد برا برنامه تعریف کنی که اگه بک گراند imageview چیزی که میخوای  شد متغیر برابر با 1 بشهبعد واسه کد نویسی دکمه بنویس اگه متغیر برابر با 1 بود کاریو که میخوای انجام بده

اگه بد توضیح دادمو متوجه نشدی کامل تر بگو تا کدشو بنویسم برات

لینک ارسال
به اشتراک گذاری در سایت های دیگر

این کدی که تو اکتیویتی دارممی خوام تو دستور رندوم اگر یک اومد باتن یک عکسش but1 بشه خب تا اینجا مشکلی نیست 

حالا می خوام بگم که اگر عکسش but1 و کاربر روش کلیک کرد دستور random دوباره ریست شه

package ir.androiddostan.moshk;import java.util.Random;import android.R.string;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.renderscript.Sampler.Value;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.TextView;public class game extends Activity {protected void onCreate(Bundle savedInstanceState) {	super.onCreate(savedInstanceState);	setContentView(R.layout.game);TextView t1= (TextView) findViewById(R.id.textView1);TextView t2= (TextView) findViewById(R.id.textView2);TextView t3= (TextView) findViewById(R.id.textView3);	Button b1 =(Button) findViewById(R.id.button1);	Button b2 =(Button) findViewById(R.id.button2);	Button b3 =(Button) findViewById(R.id.button3);	Button b15 =(Button) findViewById(R.id.button4);	Button b4 =(Button) findViewById(R.id.Button01);	Button b5 =(Button) findViewById(R.id.Button02);	Button b6 =(Button) findViewById(R.id.Button03);	Button b7 =(Button) findViewById(R.id.Button04);	Button b8 =(Button) findViewById(R.id.Button05);	Button b9 =(Button) findViewById(R.id.Button06);	Button b10 =(Button) findViewById(R.id.Button07);	Button b11 =(Button) findViewById(R.id.Button08);	Button b12 =(Button) findViewById(R.id.Button09);	Button b13 =(Button) findViewById(R.id.Button10);	Button b14 =(Button) findViewById(R.id.Button12);	Button b16 =(Button) findViewById(R.id.Button11);	Random r=new Random();	int ra=r.nextInt(17);	switch (ra) {	case 1:		b1.setBackgroundResource(R.drawable.but1);			break;	case 2:		b2.setBackgroundResource(R.drawable.but1);			break;	case 3:		b3.setBackgroundResource(R.drawable.but1);			break;	case 4:		b4.setBackgroundResource(R.drawable.but1);			break;	case 5:		b5.setBackgroundResource(R.drawable.but1);			break;	case 6:		b6.setBackgroundResource(R.drawable.but1);			break;	case 7:		b7.setBackgroundResource(R.drawable.but1);			break;	case 8:		b8.setBackgroundResource(R.drawable.but1);			break;	case 9:		b9.setBackgroundResource(R.drawable.but1);			break;	case 10:		b10.setBackgroundResource(R.drawable.but1);			break;	case 11:		b11.setBackgroundResource(R.drawable.but1);			break;	case 12:		b12.setBackgroundResource(R.drawable.but1);			break;	case 13:		b13.setBackgroundResource(R.drawable.but1);			break;	case 14:		b14.setBackgroundResource(R.drawable.but1);			break;	case 15:		b15.setBackgroundResource(R.drawable.but1);			break;	case 16:		b16.setBackgroundResource(R.drawable.but1);			break;	}}}
لینک ارسال
به اشتراک گذاری در سایت های دیگر

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...