0
그래서 잠시 동안 내 프로젝트에 한 쌍의 탭을 구현하려고했습니다. 나는 그것을하는 법에 대해 꽤 많이 읽었고 그것이 왜 효과가 없는지 확신 할 수 없다. 아무도 내가 뭘 잘못하고 있다고 말할 수 있습니까? 여기 내 .cs안드로이드 탭이 제대로 작동하지 않습니다. C#
public class TabActivity1 : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.Text = "Tab 1";
SetContentView(textview);
}
}
public class TabActivity2 : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.Text = "Tab 2";
SetContentView(textview);
}
}
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
TabHost tab_host = FindViewById<TabHost>(Resource.Id.tabHost);
TabHost.TabSpec spec;
Intent intent;
intent = new Intent(this, typeof(TabActivity1));
intent.AddFlags(ActivityFlags.NewTask);
spec = tab_host.NewTabSpec("Tab 1");
spec.SetIndicator("tab1");
spec.SetContent(intent);
tab_host.AddTab(spec);
intent = new Intent(this, typeof(TabActivity2));
intent.AddFlags(ActivityFlags.NewTask);
spec = tab_host.NewTabSpec("Tab 2");
spec.SetIndicator("tab2");
spec.SetContent(intent);
tab_host.AddTab(spec);
}
}
의 여기
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<TabHost
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabHost">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/linearLayout1">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</TabHost>
</LinearLayout>
Here 's의 어떤 응용 프로그램의 출력 .axml에게 있습니다.
정말 감사할만한 도움을 주시면 감사하겠습니다. 감사합니다.
예상되는 결과는 무엇입니까? 코드를보고 원하는 결과를 추측하는 것은 상당히 귀찮습니다. – hankide
탭 1과 탭 2로 레이블 된 2 개의 탭이 필요하고 각 탭에는 탭 1의 탭 1과 탭 2의 탭 2라는 텍스트 상자가 있습니다.이를 달성하려면 어떻게해야합니까? –