zkuste to
Načíst data z Database
v Cursor
a předejte tento kurzor níže uvedenou metodou, return
view
který můžete předat v setContentView(view)
public LinearLayoutCompat defaultPage(Cursor mCursor) {
LinearLayoutCompat layout = new LinearLayoutCompat(this);
layout.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayoutCompat.LayoutParams.MATCH_PARENT));
layout.setGravity(Gravity.CENTER);
layout.setOrientation(LinearLayoutCompat.VERTICAL);
for(int i=0;i<mCursor.getCount();i++) {
mCursor.moveToPosition(i);
AppCompatTextView defaultText = new AppCompatTextView(this);
defaultText.setText(mCursor.getString(mCursor.getColumnIndex("TOUR_COLUMN_NMAE")));
defaultText.setTextSize(20);
defaultText.setTypeface(null, Typeface.BOLD);
defaultText.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Toast.makeText(mContext, "Work in progress", Toast.LENGTH_SHORT).show();
}
});
layout.addView(defaultText);
}
return layout;
}