I am relatively new to android programming.I however have basic knowledge of the language and am also good in java.I am developing an app which will have an activity containing a graph,some information about the plotted info and a button.I want to implement it in such a way that i will have two layouts in my activity.In one layout(labeled as number 1 below),i want to plot a graph first.i also want to enable the user to swipe that layout so that the graph disappears and the plotted graph info is displayed.I also want to display screen indicators as illustrated belowIn the lower layout(shaded in my sketch),i want to have a button throughout.Now i don't know how to implement that.Is it through view flipper??I will appreciate your input.
I dont have time to explain and write a simple example so i m posting a copy of simple code i m using in my project first create like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/billboard_ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#eeeeee"
>
<android.support.v4.view.ViewPager
android:id="@+id/intro_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
>
</android.support.v4.view.ViewPager>
</LinearLayout>
in your activity-----
IntroWindowAdapter adapter = new IntroWindowAdapter(this, imageUrls);
ViewPager myPager = (ViewPager) findViewById(R.id.intro_viewpager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(0);
this one is adapter
public class IntroWindowAdapter extends PagerAdapter {
Activity activity;
String imageUrls[];
private int lptMargin = 25;
public IntroWindowAdapter(Activity activity, String[] imageArr) {
this.imageUrls = imageArr;
this.activity = activity;
}
@Override
public int getCount() {
return imageUrls.length;
}
@Override
public void destroyItem(View arg0, int arg1, Object arg2) {
((ViewPager) arg0).removeView((View) arg2);
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == ((View) arg1);
}
@Override
public Parcelable saveState() {
return null;
}
public Object instantiateItem(View collection, int position) {
ImageView view = new ImageView(activity);
view.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
view.setScaleType(ScaleType.FIT_XY);
new ImageLoader(activity).loadAndDisplayImage(imageUrls[position], view, Constants.ImageSize.NORMAL);
((ViewPager) collection).addView(view, 0);
return view;
}
}