prøv dette
Hent data fra Database
i Cursor
og giv denne markør ind nedenfor metode, den vil return
en view
som du kan sende i 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;
}