在问答应用程序中,我想在每个问题下添加一张图片



我想在每个问题下面添加一张图片。我正在使用安卓工作室。

String questions[] = {
"Which method can be defined only once in a program?",
"Which of these is not a bitwise operator?",
"Which keyword is used by method to refer to the object that invoked it?"};
String answers[] = {"main method","<=","this"};
String opt[] = {
"finalize method","main method","static method","private method",
"&","&=","|=","<=",
"import","this","catch","abstract"};

有人能帮忙吗?

您可以使用Picasso来实现这一点。按照设置说明,然后只需添加和编辑这一行:

Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView);

imageView是xml布局文件中的imageView。

我假设您的问题在TextView中输出。在这种情况下,您可以从TextView(tv1.getText().toString(中获取文本,然后将结果值与循环中的每个数组元素(tv1.getText.toString.equals(questions[n])(进行比较,这样您就可以为每个文本设置自己的图像。

最新更新