Display Image for Numbers in Count

时间:2018-06-19 11:15:57

标签: android

I have created a roundbutton. I want to display this roundbutton for the number in the count. The count represents the number of button presses. For example if the count equals 2 then 2 roundbutton must appear on the screen. Instead of me having to put each button on the screen and making it invisible at first then visible depending on the count.

roundbutton

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FF2A2A" />
<corners android:bottomRightRadius="10dp"
    android:bottomLeftRadius="10dp"
    android:topRightRadius="10dp"
    android:topLeftRadius="10dp"/>
</shape>

2 个答案:

答案 0 :(得分:0)

设置计时器并每秒更改一次图像,但是因为这将是一个计时器...您需要使用可运行的方法来更改图像,该方法的行为类似于UI线程。

答案 1 :(得分:0)

在您的代码中,更改计数后,您可能会更改为:

btnBack.setImageResource(R.drawable.ic_camera); 

对于更改可见性,您也可以使用:

View.setVisibility(View.GONE / View.VISIBLE / View.INVISIBLE)