0
這是我的第一篇文章,我希望在發帖之前,我已經找遍了。更多ImageView on TabActivity
我創建了我的第一個應用程序,用於研究許多示例和教程。我的應用程序具有滑動的選項卡式活動,並且功能良好。
我有兩個圖像瀏覽,一個選項卡,第二個選項卡。當我使用Intent編寫public void imageclick來打開一個新的活動時,每個圖像調用相同的活動,但它應該爲不同的圖像打開不同的活動。
我無法設置Findviewbyid來指示我點擊的圖像。
public class welcome extends ActionBarActivity implements android.support.v7.app.ActionBar.TabListener{
private ViewPager tabsviewPager;
private ActionBar mActionBar;
private Tabsadapter mTabsAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
tabsviewPager = (ViewPager) findViewById(R.id.tabspager);
mTabsAdapter = new Tabsadapter(getSupportFragmentManager());
tabsviewPager.setAdapter(mTabsAdapter);
getSupportActionBar().setHomeButtonEnabled(false);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Tab friendstab = getSupportActionBar().newTab().setText("Lo Staff").setTabListener(this);
Tab publicprofiletab = getSupportActionBar().newTab().setText("La Storia").setTabListener(this);
Tab communitytab = getSupportActionBar().newTab().setText("Creazioni").setTabListener(this);
getSupportActionBar().addTab(friendstab);
getSupportActionBar().addTab(publicprofiletab);
getSupportActionBar().addTab(communitytab);
//This helps in providing swiping effect for v7 compat library
tabsviewPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// TODO Auto-generated method stub
getSupportActionBar().setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
// TODO Auto-generated method stub
}
@Override
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub
}
});
}
// Intent creat = new Intent(getApplicationContext(), collezioni.class);
//startActivity(creat);
public void imageClick (View view) {
Intent creat = new Intent(getApplicationContext(),collezioni.class);
startActivity(creat);
}
@Override
public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
@Override
public void onTabSelected(Tab selectedtab, FragmentTransaction arg1) {
// TODO Auto-generated method stub
tabsviewPager.setCurrentItem(selectedtab.getPosition()); //update tab position on tap
}
@Override
public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
}