【问题标题】:Change content of a page in 4 page in ViewPager在 ViewPager 中更改 4 页中的页面内容
【发布时间】:2013-06-06 12:09:30
【问题描述】:

目前,我有一个 viewpager 并添加了 4 页。 我也有 4 个按钮对应于 4 页.. 单击button1时,仅加载page1的内容 单击button2时,仅加载page2的内容 ...vv 在android中,是否有功能可以在viewpager的页面中只为一个页面设置内容??

【问题讨论】:

    标签: android calendar android-viewpager


    【解决方案1】:

    这可能与 Using buttons within a ViewPager. 重复

    这个答案来自同一个问题:

     LayoutInflater inflater = (LayoutInflater) collection.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE)
     View v = null;
    switch (position) {
    case 0:
        v = inflater.inflate(R.layout.somelayout);
        Button btn = (Button) v.findViewById(R.id.somebutton);
        btn.setText("btn");
    break;
    
    case 1:
        v = inflater.inflate(R.layout.someotherlayout);
        TextView tv = (Button) v.findViewById(R.id.sometextview);
        tv.setText("btn");
    break;
    

    }

    ((ViewPager) collection).addView(v, 0);
    return v;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多