我正在尝试使用ViewPage来显示一些数据,例如来自SQLite的学生名称。当我在列表视图上显示信息时,它运行良好。现在我想在ViewPage中查看每个学生记录,其中一个页面只包含一个学生记录。我从SQLite中获取信息并将其放在列表中但我无法在ViewPage中显示它。
这是我的OnCreateView方法:
public View OnCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
View rootView=inflater.inflate(R.layout.fragment_main, container, false);
TextView textView=(TextView) rootView.findViewById(R.id.section_Label);
//I used the code bellow to display the data on listView which worked fine
//textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER));
// I now try to the the following to display it on ViewPage
List<String> quotes=databaseAccess.getQuotes//I the getQuotes class is bellow
textView.setText(quotes);//I assume this suppose to put each of the list element in the PageView
我的getQuotes类是:
public List<String> getQuotes() {
List<String> list=new ArrayList<>();
Cursor cursor= database.rawQuery("SELECT * FROM quotes", null;
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
list.add(cursor.getString(0));
cursor.moveToNext();
}
cursor.close();
return list;
}
}
我需要帮助。我是以错误的方式做的,或者我需要调整一些东西。 提前谢谢