0

目前,我有一个浏览器并添加了 4 页。我也有 4 个按钮对应于 4 个页面。当单击按钮 1 时,仅加载页面 1 的内容 单击按钮 2 时,仅加载页面 2 的内容 ...vv 在 android 中,是否具有仅在 viewpager 页面中设置页面内容的功能? ?

4

1 回答 1

0

这是在 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;
于 2013-06-06T04:09:30.773 回答