Android 将文本更改为True或False
我有一个布尔值,它根据方法结果返回True或False 我想制作一个大的文本,每次都根据布尔值写TRUE或FALSE 我该怎么做?Android 将文本更改为True或False,android,Android,我有一个布尔值,它根据方法结果返回True或False 我想制作一个大的文本,每次都根据布尔值写TRUE或FALSE 我该怎么做? 这是一个爆裂照相机 问题是,我用相机作为一个按钮,每次有人触摸相机,它都会返回FALSE,而每次相机在没有人将其设置为黑暗的情况下拍照,它都会返回TRUE 如果出现FALSE,相机将转到另一个活动。 真与假的事情都很好,但我只能在我的日志上查看 我只需要一个按钮,而不是写在应用程序界面的文本 public static boolean ImagemEscura(Bi
这是一个爆裂照相机 问题是,我用相机作为一个按钮,每次有人触摸相机,它都会返回FALSE,而每次相机在没有人将其设置为黑暗的情况下拍照,它都会返回TRUE 如果出现FALSE,相机将转到另一个活动。
真与假的事情都很好,但我只能在我的日志上查看 我只需要一个按钮,而不是写在应用程序界面的文本
public static boolean ImagemEscura(Bitmap img)
{
float totalpixel = img.getWidth() * img.getHeight();
float totalpixelescuro = 0;
for(int x = 0; x < img.getWidth(); x++)
{
for(int y = 0; y < img.getHeight(); y++)
{
int cor = img.getPixel(x, y);
if(SomaRGB(cor) > 90)
{
totalpixelescuro++;
}
}
}
return totalpixelescuro/totalpixel > 0.75f;
}
public static int SomaRGB(int cor)
{
return getRed(cor) + getGreen(cor) + getBlue(cor);
}
public static int getRed(int argb)
{
return argb >> 16 & 0xFF;
}
public static int getGreen(int argb)
{
return argb >> 8 & 0xFF;
}
public static int getBlue(int argb)
{
return argb & 0xFF;
}
}
公共静态布尔图像mescura(位图img)
{
float totalpixel=img.getWidth()*img.getHeight();
float totalpixelescuro=0;
对于(int x=0;x90)
{
totalpixelescuro++;
}
}
}
返回TotalPixeleScro/totalpixel>0.75f;
}
公共静态int SomaRGB(int cor)
{
返回红色(cor)+绿色(cor)+蓝色(cor);
}
公共静态int-getRed(int-argb)
{
返回argb>>16&0xFF;
}
公共静态int-getGreen(int-argb)
{
返回argb>>8&0xFF;
}
公共静态int getBlue(int argb)
{
返回argb&0xFF;
}
}
如果函数返回布尔值,则检查返回值是否为true
或false
。然后相应地设置TextView
您可以将其添加到代码中
Boolean result=your_class.ImagemEscura(your_bitmap);
if(result)
your_textview.setText("TRUE");
else
your_textview.setText("FALSE");
这可以在一行中完成:
mYourTextView.setText(String.valueOf(ImagemEscura(bitmap)));
your_textview.setText(your_class.ImagemEscura(your_bitmap) ? "TRUE" : "FALSE");
您可以在一行中完成此操作:
mYourTextView.setText(String.valueOf(ImagemEscura(bitmap)));
your_textview.setText(your_class.ImagemEscura(your_bitmap) ? "TRUE" : "FALSE");
发布你为实现这一目标而编写的代码。你必须做出决定。如果不知道你想要实现什么,很难说出这一点。。