gpt4 book ai didi

java - 安卓开发 : Implementing MCQ quiz app

转载 作者:行者123 更新时间:2023-11-30 03:01:41 24 4
gpt4 key购买 nike

我是 Android 应用开发的初学者,正在尝试构建一个简单的 MCQ 测验应用。

我所做的是制作一个二维数组,并在其中存储问题、可能的答案和正确的解决方案。

这张图片中可以看到表格中的示例:

enter image description here

所以我命名了我的数组数据库。创建这个名为 database[][] 的数组的代码如下:

    database = new String[][]{
{"Before marking the finishing line on a running track, a groundsman measures out its 100 m length. Which instrument is the most appropriate for this purpose?",
"measuring tape","metre rule","30 cm ruler","micrometer", "A"},
{"A car of mass 1500 kg travels along a horizontal road. It accelerates steadily from 10 m / s to 25 m / s in 5.0 s. What is the force needed to produce this acceleration?",
"300N","500N","4500N","D.7500N", "C"},
{"A lorry of mass 10 000 kg takes 5000 kg of sand to the top of a hill 50 m high, unloads the sand and then returns to the bottom of the hill. The gravitational field strength is 10 N / kg. What is the overall gain in potential energy?",
"250 000 J","750 000 J","2 500 000 J","D.7 500 000J", "C"},
{"A liquid-in-glass thermometer contains mercury. Which physical property of the mercury varies with temperature, enabling the thermometer to operate?",
"mass","melting point","resistance","volume", "D"},
{"Thermal energy of 12 000 J is supplied to a 2.0 kg mass of copper. The specific heat capacity of copper is 400 J / (kg °C). What is the rise in temperature?",
"15 Degree C","30 Degree C","60 Degree C","100 Degree C", "A"},
};

所以每一行基本上都是一个新问题,有自己的一组可能答案。

至于界面,有一个显示问题的textview。有四个按钮显示每个答案。你点击一个按钮来回答。然后显示下一个问题。

    textviewQuestion.setText(database[x][y]);
buttonA.setText("A. " + database[x][1]);
buttonB.setText("B. " + database[x][2]);
buttonC.setText("C. " + database[x][3]);
buttonD.setText("D. " + database[x][4]);



现在我的问题是,如果我想让这个应用程序更加通用,使用其他方式来实现问题是否更好?我的意思是也许我可以将问题存储在文本文件中?还是应该使用 SQLite?我不知道优缺点,基本上有什么限制?

我有 pdf 格式的问题,那么我可以使用它以某种方式将这些问题直接从 pdf 链接到应用程序吗?

我还希望能够提出包含一些图像的问题。如何实现?请帮我指出一些好的资源。非常感谢!

最佳答案

以下代码有助于在您的应用中打开 pdf

File pdfFile = new File(path); 
if(pdfFile.exists())
{

Uri path = Uri.fromFile(pdfFile);
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path, "application/pdf");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try
{
startActivity(pdfIntent);
}
catch(ActivityNotFoundException e)
{
Toast.makeText(uractivity.this, "File does not exist", Toast.LENGTH_LONG).show();
}
}

关于java - 安卓开发 : Implementing MCQ quiz app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22422973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com