Kekis2014 Kekis2014 - 1 year ago 80
Java Question

Is there any way to include a ViewPager in a listView to transition from one picture to another?

I'm currently making an application that is supposed to have a

that contains a
and under the
it is supposed to have one
that contains many images, but that I can only see one image at a time. I want to be able to swipe on the
so that I can transition from one picture to another without having to leave the activity. Is there any way to include a
as seen in but have it inside the
or something similar in order to accomplish this? In case it is helpful I have included my custom adapter that currently only supports the text and one image.

public class MyAdapter extends BaseAdapter {
private Context mContext;
private List<Bean> mList;
private PopupWindow popUpWindow;
private LayoutInflater inflater;

public MyAdapter(Context context,List<Bean> list){


public int getCount() {
return mList.size();

public Object getItem(int position) {
return mList.get(position);

public long getItemId(int position) {
return position;

public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
//use convertView recycle
holder=new ViewHolder();
convertView = LayoutInflater.from(mContext).inflate(R.layout.content_orders, parent, false);
holder.textView= (TextView) convertView.findViewById(;
holder.imageView= (ImageView) convertView.findViewById(;
holder.information= (Button) convertView.findViewById(;
holder = (ViewHolder) convertView.getTag();

//set text and url
final View finalConvertView = convertView;
holder.information.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup container = (ViewGroup) inflater.inflate(R.layout.information_popup, null);
popUpWindow = new PopupWindow(container, 800,400,true);
popUpWindow.showAtLocation(finalConvertView.findViewById(, Gravity.CENTER, 0,0);

container.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;


return convertView;

class ViewHolder{
TextView textView;
ImageView imageView;
Button information;
Button close;


Answer Source

I ended up not being able to figure out how to do this using the viewPager, but I found out how to do it using a horizontalScrollView. Here is the link to the question with the answer that I posted.

Adding a Horizontal Scroll View to a ListView

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download