Note that there are some explanatory texts on larger screens.

plurals
  1. POMisunderstanding with viewpager
    primarykey
    data
    text
    <p>Can I do different activity in instantiateItem() ? please check my screenshot link..</p> <p>In this screen shot,red TextView is wrote in instantiateItem()....When drag the screen,it follow...</p> <p>So,I want to insert different layout and activity instead of this TextView..Can I code these in instantiateItem() ?</p> <blockquote> <p><a href="http://tinypic.com/view.php?pic=zlagwn&amp;s=5#.UqbeWye_80k" rel="nofollow">http://tinypic.com/view.php?pic=zlagwn&amp;s=5#.UqbeWye_80k</a></p> </blockquote> <p>This is MyPageAdapter.java</p> <pre><code>public class MyPageAdapter extends PagerAdapter { private Context ctx; public MyPageAdapter(Context ctx) { this.ctx = ctx; } @Override public Object instantiateItem(ViewGroup container, int position) { LayoutInflater vi=(LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v=vi.inflate(R.layout.main, null); Button btnRefresh=(Button) v.findViewById(R.id.btnRefreshGold); btnRefresh.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub // my operation } }); ((ViewPager)container).addView(v,0); return v; } @Override public int getCount() { return 3; } @Override public void destroyItem(View container, int position, Object object) { // TODO Auto-generated method stub ((ViewPager) container).removeView((View) object); } @Override public boolean isViewFromObject(View view, Object object) { return (view == object); } </code></pre> <p>this is main.xml</p> <pre><code>&lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;/TabWidget&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;LinearLayout android:id="@+id/Tab1" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/btnRefreshGold" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/btnRefresh" /&gt; &lt;ListView android:id="@+id/myListView" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; &lt;android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="fill_parent" &gt; &lt;/android.support.v4.view.ViewPager&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload