private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(new CompanyActivity(), "ONE");
adapter.addFrag(new CompanyActivitytwo(), "TWO");
adapter.addFrag(new CompanyActivitythree(), "THREE");
viewPager.setAdapter(adapter);
}
class' CompanyActivity(),
CompanyActivitytwo(),
CompanyActivitythree()
不是片段,但我想将它们添加到片段列表中
他们都延伸AppCompatActivity
这是CompanyActivity类代码
public class CompanyActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.huf);
}
public void one(View view) {
Intent first=new Intent(CompanyActivity.this,CompanyDetalies.class);
startActivity(first);
}
public void two(View view) { Intent first=new Intent(CompanyActivity.this,CompanytwoDetalies.class);
startActivity(first);
}
public void three(View view) { Intent first=new Intent(CompanyActivity.this,CompanythreeDetalies.class);
startActivity(first);
}
public void four(View view) { Intent first=new Intent(CompanyActivity.this,CompanyfourDetalies.class);
startActivity(first);
}
public void five(View view) { Intent first=new Intent(CompanyActivity.this,CompanyfiveDetalies.class);
startActivity(first);
}
public void six(View view) {
Intent first=new Intent(CompanyActivity.this,CompanysixDetails.class);
startActivity(first);
}
}