set image on a button in android?

前端 未结 2 585
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 07:43

i have been trying to set a image on a button using the following code but it doesn\'t seem to work...i think what i am doing wrong is the path of the image i am using but i tri

相关标签:
2条回答
  • 2021-02-06 08:24

    You can use the "Image Button" it's better for you ,,, and the code like this :

    final ImageButton next = (ImageButton) findViewById(R.id.Button02) ;
    Drawable d = Drawable.createFromPath("@drawable/finalarrow1");
    next.enter.setImageDrawable(d);
    
    0 讨论(0)
  • 2021-02-06 08:29

    Why not use

    final Button next = (Button) findViewById(R.id.Button02);
    next.setBackgroundResource(R.drawable.finalarrow1);
    
    0 讨论(0)
提交回复
热议问题