나는 android app을 제작하고 있습니다. 에는 4 개의 버튼 (a, b, c, d)이있는 시작 화면이 있습니다.Tabhost의 활약 1 현재 항목을 사용한 활동
아무 단추 (a, b, c, d)를 클릭하면 두 번째 활동으로 넘어갑니다. 다음 활동에는 (탭 호스트) 네 개의 탭 (a, b, c, d)이 있습니다.
는 그것이 두 번째 활동 "탭"에 간다
내가 시작 화면에서 "A"버튼을 클릭
을 work-- 수있는 방법, 다른 탭도 노력하고 있습니다.환영 화면에서 "b"버튼을 클릭하면 두 번째 활동의 "b 탭"으로 이동하고 다른 탭도 작동합니다.
환영 화면에서 "c"버튼을 클릭하면 두 번째 활동의 "c 탭"으로 이동하고 다른 탭도 작동합니다.
환영 화면에서 "d"버튼을 클릭하면 두 번째 활동의 "d 탭"으로 이동하고 다른 탭도 작동합니다.
public class Dashboard extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard);
}
public void helpB(View v) {
Button clickedButton = (Button) v;
switch (clickedButton.getId()) {
case R.id.points:
Intent i = new Intent(getApplicationContext(),AndroidActivity.class);
startActivity(i);
break;
case R.id.Search:
Intent i1 = new Intent(getApplicationContext(),AppleActivity.class);
startActivity(i1);
break;
case R.id.AboutUs:
Intent i2 = new Intent(getApplicationContext(),BlackBerryActivity.class);
startActivity(i2);
break;
case R.id.ContactUs:
Intent i3 = new Intent(getApplicationContext(),WindowsActivity.class);
startActivity(i3);
break;
}
}
}
과 두 번째 활동 코드 ->
public class MainActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources ressources = getResources();
TabHost tabHost = getTabHost();
// Android tab
Intent intentAndroid = new Intent().setClass(this,
AndroidActivity.class);
TabSpec tabSpecAndroid = tabHost
.newTabSpec("Android")
.setIndicator("Points",
ressources.getDrawable(R.drawable.icon_android_config))
.setContent(intentAndroid);
// Apple tab
Intent intentApple = new Intent().setClass(this, AppleActivity.class);
TabSpec tabSpecApple = tabHost
.newTabSpec("Apple")
.setIndicator("Search",
ressources.getDrawable(R.drawable.icon_apple_config))
.setContent(intentApple);
// Windows tab
Intent intentWindows = new Intent().setClass(this,
WindowsActivity.class);
TabSpec tabSpecWindows = tabHost
.newTabSpec("Windows")
.setIndicator("About us",
ressources.getDrawable(R.drawable.icon_windows_config))
.setContent(intentWindows);
// Blackberry tab
Intent intentBerry = new Intent().setClass(this,
BlackBerryActivity.class);
TabSpec tabSpecBerry = tabHost
.newTabSpec("Berry")
.setIndicator(
"Contact us",
ressources
.getDrawable(R.drawable.icon_blackberry_config))
.setContent(intentBerry);
// add all tabs
tabHost.addTab(tabSpecAndroid);
tabHost.addTab(tabSpecApple);
tabHost.addTab(tabSpecWindows);
tabHost.addTab(tabSpecBerry);
// set Windows tab as default (zero based)
tabHost.setCurrentTab(0);
}
}
정확히 문제가 무엇입니까? –
대시 보드 활동에서 MainActivity로 이동합니다 ... DashboardActivity에서 주 활동의 4 개의 탭과 동일한 4 개의 단추가 있습니다. 대시 보드 활동의 특정 단추를 클릭하면 특정 탭으로 이동합니다. 버튼 이름과 탭 이름은 동일합니다 .. 대시 보드 활동에 대한 aboutus 버튼을 클릭하기 만하면됩니다. 우리 탭에 대한 탭 이동 탭 기본 탭 표시 – Amardeepvijay
이동해서는 안되나요? 나는 아직도 문제를 이해하지 못했다. –