This question already has answers here:
Displaying images from specific folder in sd card in grid view
(4 answers)
Closed 3 years ago.
I had developed an application where I want to display images inside grid view from specific folder of sd card. The application is working but only 1st image from folder is appearing in every grid, while I want all images should display. I am not getting where I went wrong.
Below, I am posting my code:
Album Activity:
public class Album3Activity extends Activity {
static File [] mediaFiles;
static File imageDir;
GridView gridView;
ImageAdapter adapter;
Intent in;
public static final String TAG = "Album3Activity";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid);
prepareList();
adapter = new ImageAdapter(this, mediaFiles);
gridView = (GridView)findViewById(R.id.gridview);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
in = new Intent(getApplicationContext(), FullScreen.class);
in.putExtra("id", position);
startActivity(in);
}
});
}//onCreate
public static Bitmap prepareList() {
imageDir = new File(Environment.getExternalStorageDirectory().toString()+
"/diplomat");
mediaFiles = imageDir.listFiles();
Bitmap bmp = null;
for(File imagePath:mediaFiles){
try{
bmp = BitmapFactory.decodeStream(imagePath.toURL().openStream());
}catch(Exception e){
Log.d(TAG, "Exception: "+e.toString());
}//catch
}//for
Log.d(TAG, "prepareList() called");
return bmp;
}//prepareList
}//class
Image Adapter:
public class ImageAdapter extends BaseAdapter{
Activity act;
File[] mFiles;
public static final String TAG = "ImageAdapter";
public ImageAdapter(Activity act, File[] mFiles){
super();
this.act = act;
this.mFiles = mFiles;
}//ImageAdapter
public int getCount() {
return mFiles.length;
}//getCount
public Object getItem(int postion) {
return mFiles[postion];
}//getItem
public long getItemId(int position) {
return 0;
}//getItemId
public static class ViewHolder{
ImageView iv;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder view;
LayoutInflater li = act.getLayoutInflater();
if(convertView == null){
view = new ViewHolder();
convertView = li.inflate(R.layout.gridview_row, null);
view.iv = (ImageView)convertView.findViewById(R.id.imageView1);
convertView.setTag(view);
}//if
else{
view = (ViewHolder)convertView.getTag();
}//else
Bitmap bmp = Album3Activity.prepareList();
view.iv.setImageBitmap(bmp);
Log.d(TAG, "getView called");
return convertView;
}//getView
}//ImageAdapter
Note prepareList method, it is not returning bitmap according to the position or index of the imageview, so it would return same image all the time, change it to accept an index parameter, and return bitmap accordingly, as:
public static Bitmap prepareList(int index) {
imageDir = new File(Environment.getExternalStorageDirectory().toString()+
"/diplomat");
mediaFiles = imageDir.listFiles();
File imagePath=imageDir[index];
Bitmap bmp = null;
try{
bmp = BitmapFactory.decodeStream(imagePath.toURL().openStream());
}catch(Exception e){
Log.d(TAG, "Exception: "+e.toString());
}//catch
Log.d(TAG, "prepareList() called");
return bmp;
}//prepareList
In getView everytime your are calling album3Activity.prepareList() so it will return single image for all the grid. Try with the passing the particular imagepath in mFiles[position] each time and get the bitmap or get all the bitmap at once and store it in arrayList and pass the arraylist to adapter and use it in getView.
Try this..it may help you..
Related
I want show image in gridview from sdcard directory.i use this code.But when i load image by type : bitmap.getView in gridview adapter need Integer[] array.how i can fix it?
public class LoadPic extends Activity {
Integer[] imageIDs = {
R.drawable.user,
R.drawable.user,
R.drawable.user,
R.drawable.user,
R.drawable.user,
R.drawable.user,
R.drawable.user
};
int numberOfImages=0;
Bitmap[] m;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.load_pic);
Intent gett = getIntent();
String _area = gett.getStringExtra("area");
String _domain = gett.getStringExtra("domain");
String _block = gett.getStringExtra("block");
String _melk = gett.getStringExtra("melk");
String _build = gett.getStringExtra("build");
String _apar = gett.getStringExtra("apar");
String _senfi = gett.getStringExtra("senfi");
File dir = new File(Environment.getExternalStorageDirectory()
+ "/momayezi/"+_area+"-"+_domain+"-"+_block+"-"+_melk+"-"+_build+"-"+_apar+"-"+_senfi);
File[] files = dir.listFiles();
numberOfImages=files.length;
for (int i=1;i<=numberOfImages;i++)
{
File img = new File("/sdcard/momayezi/"+_area+"-"+_domain+"-"+_block+"-"+_melk+"-"+_build+"-"+_apar+"-"+_senfi+"/pic"+i+".png");
if(img.exists())
{
Bitmap bit = BitmapFactory.decodeFile(img.getAbsolutePath());
}
}
GridView gridView = (GridView) findViewById(R.id.gridview);
gridView.setAdapter(new ImageAdapter(this));
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent,
View v, int position, long id) {
Toast.makeText(getBaseContext(),
"pic" + (position + 1) + " selected",
Toast.LENGTH_SHORT).show();
}
});
}
public class ImageAdapter extends BaseAdapter
{
private Context context;
public ImageAdapter(Context c)
{
context = c;
}
//---returns the number of images---
public int getCount() {
return numberOfImages;
}
//---returns the ID of an item---
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
//---returns an ImageView view---
public View getView(int position, View convertView, ViewGroup parent)
{
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(context);
imageView.setLayoutParams(new GridView.LayoutParams(185, 185));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(7, 7, 7, 7);
} else {
imageView = (ImageView) convertView;
}
/**/
imageView.setImageResource(imageIDs[position]);
/**/
return imageView;
}
}
}
please help how i can use image in this class(adapter).
If you want to show images from sdcard into your grid view use any imageloader library
Universal Image Loader
https://github.com/nostra13/Android-Universal-Image-Loader
then you need to create a string array or a model class instead of that integer array.
Please refer the below tutorials.
http://wptrafficanalyzer.in/blog/loading-thumbnail-images-in-a-gridview-and-opening-original-images-in-alertdialog-using-media-content-providers/
replace
public int getCount() {
return numberOfImages;
}
with
public int getCount() {
return imageIDs.length();
}
First properly explain what do want to set Drawable or Bitmap?
If Bitmap then this is how you should set bitmap(make a list of bitmaps and then):
imageView.setImageBitmap(bitmaps[position]);
if Drawable then(make list of drawable id's)
imageview.setImageResource(drawables[position]);
This is how make bitmap list:
ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>();
File dir = new File(Environment.getExternalStorageDirectory()
+ "/momayezi/"+_area+"-"+_domain+"-"+_block+"-"+_melk+"-"+_build+"-"+_apar+"-"+_senfi);
File[] files = dir.listFiles();
numberOfImages=files.length;
for (int i=1;i<=numberOfImages;i++)
{
File f = new File("/sdcard/momayezi/"+_area+"-"+_domain+"-"+_block+"-"+_melk+"-"+_build+"-"+_apar+"-"+_senfi+"/pic"+i+".png");
Bitmap bmp = BitmapFactory.decodeFile(f.getAbsolutePath());
if(bmp!=null){
bitmaps.add(bmp);
}
}
I previously posted about storing and retrieving references to images in my application's file system HERE. I got some insight into how I should store those references in my Sq-lite database and decided to store the "name" of the image in a designated column.
Currently the code I am using allows me to display all the captured images in a grid-view, by directly accessing the folder from the directory:
MainActivity.java
public class MainActivity extends Activity{
//Initializing Variables:
private String[] FilePathStrings;
private String[] FileNameStrings;
private File[] listFile;
GridView grid;
GridViewAdapter adapter;
File file;
#Override
protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.onCreate(savedInstanceState);
setContentView(R.layout.closetui);
// Check device for SD Card:
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
Toast.makeText(this, "Error! No SDCARD Found!", Toast.LENGTH_LONG).show();
}
else
{
// Locate the item_images folder in your SD Card:
file = new File(Environment.getExternalStorageDirectory() + File.separator + "item_images");
// Create a new folder if no folder named item_images exist:
file.mkdirs();
}
if (file.isDirectory())
{
//Creating a list of files from the "item_images" folder:
listFile = file.listFiles();
// Create a String array for FilePathStrings:
FilePathStrings = new String[listFile.length];
// Create a String array for FileNameStrings:
FileNameStrings = new String[listFile.length];
for (int i = 0; i < listFile.length; i++)
{
// Get the path of the image file:
FilePathStrings[i] = listFile[i].getAbsolutePath();
// Get the name image file:
FileNameStrings[i] = listFile[i].getName();
}
}
// Locate the GridView in activityMain.xml:
grid = (GridView) findViewById(R.id.gridview);
// Pass String arrays to GridViewAdapter Class:
adapter = new GridViewAdapter(this, FilePathStrings, FileNameStrings);
// Set the GridViewAdapter to the GridView:
grid.setAdapter(adapter);
// Capture gridview item click:
grid.setOnItemClickListener(new OnItemClickListener()
{
#Override //<?> - Generic type
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Intent i = new Intent(getApplicationContext(), ViewImage.class);
// Pass String arrays FilePathStrings:
i.putExtra("filepath", FilePathStrings);
// Pass String arrays FileNameStrings:
i.putExtra("filename", FileNameStrings);
// Pass click position:
i.putExtra("position", position);
startActivity(i);
}
});
}
}
GridViewAdapter.java
public class GridViewAdapter extends BaseAdapter {
// Variable Declarations:
private Activity activity;
private String[] filepath;
private String[] filename;
private static LayoutInflater inflater = null;
public ImageLoader imageLoader;
public GridViewAdapter(Activity a, String[] fpath, String[] fname)
{
activity = a;
filepath = fpath;
filename = fname;
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader = new ImageLoader(activity.getApplicationContext());
}
//Returns the number of images:
public int getCount()
{
return filepath.length;
}
//Returns the id of an item:
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
return position;
}
//Returns an image view:
public View getView(int position, View convertView, ViewGroup parent)
{
View vi = convertView;
if (convertView == null) vi = inflater.inflate(R.layout.gridview_item, null);
{
ImageView image = (ImageView) vi.findViewById(R.id.image);
imageLoader.DisplayImage(filepath[position], image);
return vi;
}
}
}
This works fine on its own for just displaying images in the directory, however I want to be able to retrieve and display these images based on their stored file name in the database.
In other words, I want to be able to only see images that have that reference stored in the database.
Any suggestions, sample code, feedback is welcomed.
Here I am getting stored picture paths from the database. So that I am showing the images in the gridview with the help of paths. But as it is shown in my code below, I am loading cursoradapter in the asynctask. The problem here is for the first time it is okay that it takes some time until all images are loaded.
But if user adds one more pic to the database, it again takes much time to load all images as I kept the asynctask in onResume() to make the added picture also visible. The same is the case whenever user adds each picture. Can someone suggest me a simple way to get the last added picture visible in the gridview without having to load all the pictures again. Or in the least case can some one help me implementing lazy adapter to the present cursoradapter if that is not possible?
public class ImagesScreen extends Activity {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.images_screen);
gridView = (GridView)findViewById(R.id.gridView1);
String[] from = new String[] { Reminders.MOM_PATHS };
int[] to = new int[] {};
dbCon = new SQLiteConnectClass(ImagesScreen.this);
imageCursorAdapter = new ImageCursorAdapter(ImagesScreen.this, R.layout.griditem, null, from, to);
gridView.setAdapter(imageCursorAdapter);
}
protected void onResume() {
super.onResume();
new GetImages().execute((Object[]) null);
}
private class GetImages extends AsyncTask<Object, Object, Cursor> {
#Override
protected Cursor doInBackground(Object... params) {
return dbCon.getAllImages();
}
#Override
protected void onPostExecute(Cursor result) {
imageAdapter.changeCursor(result);
}
public void addpictures(View view){
// code for adding picture paths to the database by transferring to another activity.
}
}
CustomAdapter class:
public class ImageCursorAdapter extends SimpleCursorAdapter{
private int layout;
private LayoutInflater mLayoutInflater;
private Context mContext;
public ImageAdapter(Context context, int layout, Cursor c,String[] from, int[] to) {
super(context, layout, c, from, to,0);
this.layout = layout;
mLayoutInflater=LayoutInflater.from(context);
mContext = context;
}
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View v = mLayoutInflater.inflate(layout, parent, false);
return v;
}
public void bindView(final View v, final Context context, Cursor c) {
final int id = c.getInt(c.getColumnIndex("id"));
final String imagepath = c.getString(c.getColumnIndex("paths"));
ImageView imageview = (ImageView)v.findViewById(R.id.imageView1);
File imgFile = new File(imagepath);
if(imgFile.exists()){
Bitmap imageBitmap = decodeFile(imgFile);
imageview.setImageBitmap(imageBitmap);
}
}
}
use this code
public class Imagegallery extends Activity implements OnItemClickListener,
OnScrollListener, OnTouchListener {
Button btn;
SQLiteDatabase sampleDB = null;
String SAMPLE_DB_NAME = "hic";
int size = 0;
TextView headertext;
Button cartbtn;
ImageView footer1, footer2, footer3, footer4, footer5;
GridView gridView;
boolean larg = false;
String products;
int j = 1;
int ii = 0;
String imagepath[];
String productname[];
int productid[] = new int[1000];
String productids[] = new String[1000];
int integerprodids[] = new int[1000];
final Context context = this;
String filename2[];
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.currentspecial);
File root = new File(Environment.getExternalStorageDirectory()
+ File.separator + "aiwhic/product" + File.separator);
File[] fileName = root.listFiles();
filename2 = new String[fileName.length];
for (int j = 0; j < fileName.length; j++) {
Uri uri = Uri.fromFile(fileName[j]);
filename2[j] = fileName[j].getAbsolutePath();
Log.e("file", filename2[j]);
}
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setAdapter(new ImageAdapter(this, filename2, filename2));
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
int isf = filename2[position].lastIndexOf("/");
int laf = filename2[position].lastIndexOf(".");
String filename = filename2[position].substring(isf + 1, laf);
int pos = Integer.parseInt(filename);
Intent go = new Intent(Imagegallery.this, ItemsPage.class);
Bundle bundle = new Bundle();
bundle.putInt("position", pos);
bundle.putString("whichclass", "imagegallery");
bundle.putInt("catid", 2);
go.putExtras(bundle);
startActivity(go);
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context context;
private final String[] mobileValues;
private final String[] mobileimages;
public ImageAdapter(Context context, String[] mobileValues, String[] mo) {
this.context = context;
this.mobileValues = mobileValues;
this.mobileimages = mo;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
gridView = inflater.inflate(R.layout.currentspeciallist, null);
TextView textView = (TextView) gridView
.findViewById(R.id.textView1);
textView.setText(mobileValues[position]);
textView.setVisibility(View.INVISIBLE);
ImageView imageView = (ImageView) gridView
.findViewById(R.id.imageView1);
imageView.setTag(mobileimages[position]);
new Loadimage().execute(imageView);
// imageView.setImageBitmap(BitmapFactory
// .decodeFile(mobileimages[position]));
} else {
gridView = (View) convertView;
}
return gridView;
}
public int getCount() {
return mobileimages.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
}
class Loadimage extends AsyncTask<Object, Void, Bitmap> {
private ImageView imv;
private String path;
#Override
protected Bitmap doInBackground(Object... params) {
imv = (ImageView) params[0];
path = imv.getTag().toString();
// Bitmap thumb = BitmapFactory.decodeFile(path);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 2; // for 1/2 the image to be loaded
Bitmap thumb = Bitmap.createScaledBitmap(
BitmapFactory.decodeFile(path, opts), 120, 120, false);
return thumb;
}
#Override
protected void onPostExecute(Bitmap bitmap) {
if (!imv.getTag().toString().equals(path)) {
/*
* The path is not same. This means that this image view is
* handled by some other async task. We don't do anything and
* return.
*/
return;
}
if (bitmap != null && imv != null) {
imv.setVisibility(View.VISIBLE);
imv.setImageBitmap(bitmap);
} else {
imv.setVisibility(View.GONE);
}
}
}
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
}
then create a xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" >
</ImageView>
</RelativeLayout>
i am getting file path directly . u just get the name from sqlite and pass the array string
use Android-Universal-Image-Loader
and set
ImageView imageview = (ImageView)v.findViewById(R.id.imageView1);
File imgFile = new File(imagepath);
if(imgFile.exists()){
imageLoader.displayImage(imageUri(ur file path), imageView);
}
I am using the following to code make an image gallery, but I would like to use images from the web instead of from the SD card. Is there a way to do this? Currently the code requires and integer value for the image. Or do I have to download the images to the SD first?
public class viewimages extends Activity {
private Gallery gallery;
private ImageView imgView;
private Integer[] Imgid = {
R.drawable.a_1, R.drawable.a_2, R.drawable.a_3, R.drawable.a_4
};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.viewimages);
imgView = (ImageView)findViewById(R.id.ImageView01);
imgView.setImageResource(Imgid[0]);
gallery = (Gallery) findViewById(R.id.examplegallery);
gallery.setAdapter(new AddImgAdp(this));
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
imgView.setImageResource(Imgid[position]);
}
});
}
public class AddImgAdp extends BaseAdapter {
int GalItemBg;
private Context cont;
public AddImgAdp(Context c) {
cont = c;
TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
typArray.recycle();
}
public int getCount() {
return Imgid.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imgView = new ImageView(cont);
imgView.setImageResource(Imgid[position]);
imgView.setLayoutParams(new Gallery.LayoutParams(80, 70));
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
imgView.setBackgroundResource(GalItemBg);
return imgView;
}
}
}
You can do something like this:
URL url = new URL("http://www.website.com/image.jpg");
Bimtap bmp = BitmapFactory.decodeStream(url.openConnection()
.getInputStream());
Then you'll need to change where you're doing "setImageResource" to "setImageBitmap" and supply the 'bmp' object once it has been downloaded and loaded up.
[Edit]
It's also important to make sure your android manifest has internet permissions.
<uses-permission android:name="android.permission.INTERNET" />
[Edit for comment question]
If you want to do this for multiple images, and the images aren't based on an id_number (basically if the images aren't something like 0001.jpg, 0002.jpg, etc.) create a string ArrayList that will hold the names of all the items, and then iterate through it. E.g.,
List<String> imageNames = new ArrayList<String>();
imageNames.add("image.jpg");
imageNames.add("thisPhoto.jpg");
//etc. until you've added all images
for (int i = 0; i < imageNames.size(); i++){
URL url = new URL("http://www.website.com/" + imageNames.get(i));
Bimtap bmp = BitmapFactory.decodeStream(url.openConnection()
.getInputStream());
}
Hope that helps
i am trying to show my arraylist value in my tablayout. now i am successfully passed two values in my two tabhost it's working. i have three tabhost 2tab host working fine. so i am trying show my stored path value video thumb. how to show my stored path value to video thumb nail? i am trying to show but i am getting error
error is:
The type of the expression must be an array type but it resolved to ArrayList<String>
line:
imgVw.setImageBitmap(getImage(tabview.videoList[position]));
full source code:
public class video extends Activity {
//set constants for MediaStore to query, and show videos
//flag for which one is used for images selection
private Gallery _gallery;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mavideo);
//set GridView for gallery
_gallery = (Gallery) findViewById(R.id.videoGrdVw);
//set gallery adapter
setGalleryAdapter();
}
private void setGalleryAdapter() {
_gallery.setAdapter(new VideoGalleryAdapter(this));
}
//
private class VideoGalleryAdapter extends BaseAdapter
{private Context mContext;
public VideoGalleryAdapter(Context c)
{
mContext = c;
}
public int getCount()
{
return tabview.videoList.size();
}
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
ImageView imgVw= new ImageView(mContext);;
try
{
if(convertView!=null)
{
imgVw= (ImageView) convertView;
}
imgVw.setImageBitmap(getImage(tabview.videoList[position]));
imgVw.setLayoutParams(new Gallery.LayoutParams(96, 96));
imgVw.setPadding(8, 8, 8, 8);
}
catch(Exception ex)
{
System.out.println("StartActivity:getView()-135: ex " + ex.getClass() +", "+ ex.getMessage());
}
return imgVw;
}
// Create the thumbnail on the fly
private Bitmap getImage(int id) {
Bitmap thumb = MediaStore.Video.Thumbnails.getThumbnail(
getContentResolver(),
id, MediaStore.Video.Thumbnails.MICRO_KIND, null);
return thumb;
}
}
}
note:
parxmlactivity.java this is my main class here i am passing my value using below code:
sdcardImages.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
Intent intent = new Intent(ParxmlActivity.this, tabview.class);
intent.putExtra("spec",model_List.get(position).spec);
intent.putStringArrayListExtra("imageList", model_List.get(position).imageList);
intent.putStringArrayListExtra("videoList", model_List.get(position).videoList);
startActivity(intent);
}
});
and i am getting this passed value in below code in tabview.java class file:
tab_intent=tabview.this.getIntent().getExtras();
spec=tab_intent.getString("spec");
imageList = tab_intent.getStringArrayList("imageList");
videoList = tab_intent.getStringArrayList("videoList");