public class MainActivity extends AppCompatActivity {
private ViewPager vp;
private DrawerLayout drawer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawer = (DrawerLayout) findViewById(R.id.drawer);
vp = (ViewPager) findViewById(R.id.vp);
RadioGroup rg = (RadioGroup) findViewById(R.id.rg);
RadioButton rb1 = (RadioButton) findViewById(R.id.rb1);
RadioButton rb2 = (RadioButton) findViewById(R.id.rb2);
RadioButton rb3 = (RadioButton) findViewById(R.id.rb3);
final ListView lv = (ListView) findViewById(R.id.lv);
LvAdapter ada = new LvAdapter(this);
lv.setAdapter(ada);
MyAdapter adapter = new MyAdapter(getSupportFragmentManager());
vp.setAdapter(adapter);
/*
listView点击事件
*/
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
vp.setCurrentItem(position);
drawer.closeDrawer(lv);
}
});
}
}
private ViewPager vp;
private DrawerLayout drawer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawer = (DrawerLayout) findViewById(R.id.drawer);
vp = (ViewPager) findViewById(R.id.vp);
RadioGroup rg = (RadioGroup) findViewById(R.id.rg);
RadioButton rb1 = (RadioButton) findViewById(R.id.rb1);
RadioButton rb2 = (RadioButton) findViewById(R.id.rb2);
RadioButton rb3 = (RadioButton) findViewById(R.id.rb3);
final ListView lv = (ListView) findViewById(R.id.lv);
LvAdapter ada = new LvAdapter(this);
lv.setAdapter(ada);
MyAdapter adapter = new MyAdapter(getSupportFragmentManager());
vp.setAdapter(adapter);
/*
listView点击事件
*/
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
vp.setCurrentItem(position);
drawer.closeDrawer(lv);
}
});
}
}