背景がイメージのボタンにクリック可能な効果を与える方法はありますか?それは正しく機能しますが、イメージのように見えます。どんな助けもありがとう。ImageButtonsのクリック可能な効果
0
A
答えて
2
さまざまなイメージを作成してセレクタに配置する必要があります。詳細は、このチュートリアルを見てみましょう:
1
これは私が私のサイコロゲームのためにやったことです。あなたが行うことができますあなたのXMLで
:あなたが行うことができますあなたのMainActivity.Javaで
:
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.Button;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
import java.util.Random;
public class Z_veselinovic_yahtzeeActivity extends Activity
{
/** Called when the activity is first created. */
ImageButton button1, button2, button3, button4, button5;
Button start, reroll, hold;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Buttons();
}
public void Buttons()
{
button1 = (ImageButton)findViewById(R.id.dice1);
button2 = (ImageButton)findViewById(R.id.dice2);
button3 = (ImageButton)findViewById(R.id.dice3);
button4 = (ImageButton)findViewById(R.id.dice4);
button5 = (ImageButton)findViewById(R.id.dice5);
start = (Button)findViewById(R.id.Start);
reroll = (Button)findViewById(R.id.Reroll);
hold = (Button)findViewById(R.id.Hold);
reroll.setVisibility(View.GONE);
hold.setVisibility(View.GONE);
start.setOnClickListener(new OnClickListener()
{
public void onClick(View whatever)
{
Toast.makeText(getBaseContext(), start.getText() + " Game", Toast.LENGTH_LONG).show();
Random rand1 = new Random();
Random rand2 = new Random();
Random rand3 = new Random();
Random rand4 = new Random();
Random rand5 = new Random();
int dice_num_1 = rand1.nextInt(6) + 1;
int dice_num_2 = rand2.nextInt(6) + 1;
int dice_num_3 = rand3.nextInt(6) + 1;
int dice_num_4 = rand4.nextInt(6) + 1;
int dice_num_5 = rand5.nextInt(6) + 1;
if(dice_num_1 == 1)
{
button1.setImageResource(R.drawable.red_1_dice);
}
else if(dice_num_1 == 2)
{
button1.setImageResource(R.drawable.red_2_dice);
}
else if(dice_num_1 == 3)
{
button1.setImageResource(R.drawable.red_3_dice);
}
else if(dice_num_1 == 4)
{
button1.setImageResource(R.drawable.red_4_dice);
}
else if(dice_num_1 == 5)
{
button1.setImageResource(R.drawable.red_5_dice);
}
else if(dice_num_1 == 6)
{
button1.setImageResource(R.drawable.red_6_dice);
}
私はこのことができます願っています。
関連する問題
- 1. クリック可能なJavaScript
- 2. Android TextView - クリック可能なリンクとクリック可能な表示
- 3. emacsのクリック可能なテキストミニバッファ
- 4. -drawRectのクリック可能なテキスト:
- 5. ListViewのクリック可能なイメージ
- 6. ListViewのクリック可能な
- 7. Twitterのクリック可能なURL
- 8. androidのクリック可能なテキスト
- 9. GTileLayerOverlayのクリック可能なマーカー
- 10. Androidのクリック可能なレイヤー
- 11. クリック可能なdivの
- 12. クリック可能なウェブサイトのURL
- 13. 最も効果的なクリック数のカウント
- 14. クリック可能なCALayer UI
- 15. jQuery DataTableクリック可能なタイトル
- 16. LongClick textView、クリック可能なリンク
- 17. Infragisticsクリック可能なPieChart
- 18. UILabelでクリック可能なテキスト
- 19. クリック可能なparticle.js PointCloud
- 20. クリック可能な相対レイアウト
- 21. Wordpressでクリック可能なスライダ
- 22. Googleマップでクリック可能なランドマークを無効にする
- 23. iPhone SDKのスクロール可能な、クリック可能なテキスト
- 24. javascript bingマップのドラッグ可能なクリック可能な押しピン
- 25. Python GTK:クリック可能な画像のスクロール可能なグリッド
- 26. Jquery同位体 - 拡張可能な.itemのクリック可能なコンテンツ
- 27. 「フォーカス可能」と「クリック可能」の違い
- 28. クリック可能なソート可能なヘッダーを持つUITableView
- 29. ダイアログボックスのタイトルのクリック可能なアイコン
- 30. Androidのクリック可能なパネルのUI
ありがとうクリスチャン!!それは私のために働いた! – Pa1