我正在开发一个基于问答的应用程序。
我正在使用 res/raw 数据库来获取数据,我计划为此设置一个搜索选项,即,我在底部保留了一个搜索框并说我有 100 个问题,我想做的是转到第 45 个问题。通过在搜索框中输入数字。我对这方面的工作没有任何想法。请帮我找到解决方案
protected void loadQuestionset1() throws Exception {
try {
InputStream questionset1 = this.getBaseContext().getResources()
.openRawResource(R.raw.questionset1);
bReader = new BufferedReader(new InputStreamReader(questionset1));
StringBuilder quesString = new StringBuilder();
String aJsonLine = null;
while ((aJsonLine = bReader.readLine()) != null) {
quesString.append(aJsonLine);
}
Log.d(this.getClass().toString(), quesString.toString());
JSONObject quesObj = new JSONObject(quesString.toString());
quesList1 = quesObj.getJSONArray("Questions");
Log.d(this.getClass().getName(),
"Num Questions " + quesList1.length());
}
catch (Exception e){
} finally {
try {
bReader.close();
} catch (Exception e) {
Log.e("", e.getMessage().toString(), e.getCause());
}
}
}
public static JSONArray getQuesList1() {
return quesList1;
}