我已經創建圖像按鈕編程和設置我想改變圖像的圖像變化圖像編程的機器人
img = new ImageView(this);
img.setBackgroundResource(R.drawable.starred);
img.setLayoutParams(new TableRow.LayoutParams(28,28));
當圖像
img.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try
{
AlertDialog.Builder builder = new AlertDialog.Builder(Job_Description.this);
builder.setTitle("Save this Job ?");
// builder.setMessage("whould You like to save job");
builder.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
img.setImageResource(R.drawable.starapplied);
}
});
builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
dialog.cancel();
}
});
builder.show();
}catch(Exception e)
{
Log.d("Image clicked", e.toString());
}
}
});
用戶點擊我錯了在這裏做什麼?
加入這一行。 like,onClcik(view){img.setBackgroundResource(R.drawable.image);嘗試{//你的代碼//}} – Beginner
如果任何答案非常有幫助,請標記爲正確答案關閉線程;) –