I'm currently developing an android app which allow user to read notes. Basically, the notes are in jpeg file which i use a viewpager to let user swipe the notes. All the notes(jpeg) are stored in drawable folder then i call them in a java class called Customswipeadapater.
My question is, instead of calling the notes from drawable folder, can i call them from sqlite database? Is it possible? And how do i do it?
This is my code for the customswipeadapter.
package com.hciplus.sufiansobri.hci;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
public class CustomSwipeAdapter012 extends PagerAdapter {
private int [] image_resource = {R.drawable.card2,R.drawable.card3,R.drawable.card4,R.drawable.card5,R.drawable.card6,R.drawable.card7,R.drawable.card8,};
private Context ctx;
private LayoutInflater layoutInflater;
public CustomSwipeAdapter012 (Context ctx){
this.ctx = ctx;
}
@Override
public int getCount() {
return image_resource.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return (view== (RelativeLayout)object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
layoutInflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View item_view = layoutInflater.inflate(R.layout.swipe_layout012,container,false);
ImageView imageView = (ImageView) item_view.findViewById(R.id.image_view012);
imageView.setImageResource(image_resource[position]);
container.addView(item_view);
return item_view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((RelativeLayout)object);
}
}
Aucun commentaire:
Enregistrer un commentaire