2011-12-30 1 views
1

ボタンや画像の操作に問題があります。私は2つのボタンがあり、もう一方は隣にありますが、2つ目のボタンは間違った画像に見えます。いくつかのツールで画像を表示します。ここでAndroidでボタンの背景として表示される画像が間違っています

は私のコードです:ここでは

TextView categoriaText = new TextView(this); 
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 
      LayoutParams.WRAP_CONTENT); 
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); 
// use same id as defined when adding the button 
params.addRule(RelativeLayout.LEFT_OF, 1001); 
params.topMargin = top; 
params.leftMargin = 30; 
categoriaText.setLayoutParams(params); 
categoriaText.setText(_listaCategorias.get(i).getNome()); 
categoriaText.setTextSize(20); 


Button deleteBtn = new Button(this); 
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(60, 
      60); 
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); 
params2.rightMargin = 80; 
params2.topMargin = top; 
deleteBtn.setLayoutParams(params2); 

deleteBtn.setBackgroundResource(R.drawable.ic_coleccao); 
// give the button an id that we know 
deleteBtn.setId(1001); 


Button editBtn = new Button(this); 
RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(60, 
      60); 
// params2.addRule(RelativeLayout.RIGHT_OF, 1001); 
params3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); 
params3.topMargin = top; 
editBtn.setLayoutParams(params3); 
editBtn.setBackgroundResource(R.drawable.ic_edit); 

はscreenshootです: Screen Shot

第二の画像が正しいものではありません。

+0

あなたの質問はあなたが投稿したコードとは無関係です。あなたの問題はすべてコード名ではなくイメージ名になります。 –

+1

try(Eclipseメニュー)*プロジェクト>クリーン* –

+0

ありがとうございます。 –

答えて

1

Rクラスのリソースへの参照が面倒になることがよくあります。 eclipseで開発している場合は、生成されたRクラスを破棄し、eclipseを再起動して自動的に再構築させます。

関連する問題