probeer dit
Gegevens ophalen uit Database
in Cursor
en geef deze cursor door in de onderstaande methode, het zal return
een view
die u kunt doorgeven in 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;
}