PDA

View Full Version : مشکل در ایجاد TabHost



ilalia2
جمعه 15 مرداد 1395, 12:26 عصر
سلام خدمت دوستان


من یک TabHost میخوام ایجاد کنم ، برنامه نصب میشه ولی اجرا نمیشه و برنامه رو متوقف میکنه!


http://8pic.ir/images/ajh73q8c5nm1jp50l77u.jpg (http://8pic.ir/)



این هم کدهای جاوا هستش
مشکل وقتی پیش میاد که کدهای خط 16 تا 28 رو مینویسم:


141864


کدهای xml:


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.user.collection.Tabhost">

<TabHost
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabHost3"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TabWidget
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget>

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>

<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>

</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>


http://8pic.ir/images/fwvtrwxmgh4boch61xsf.jpg (http://8pic.ir/)



لطفا راهنمایی کنید.

ilalia2
جمعه 15 مرداد 1395, 12:30 عصر
یه سوال دیگه اینکه چرا خط 17 در کدهای جاوا رنگ قهوه ای شده؟
و همچنین بعضی خطوط در xml؟

hasan_esfahan
سه شنبه 19 مرداد 1395, 14:57 عصر
یک تا نکته داشت

کد زیر را بزن


<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >

<TabHost
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabHost3"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">

<LinearLayout
android:id="@+id/sadasdsa"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget>

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>

<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>

</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>

hasan_esfahan
سه شنبه 19 مرداد 1395, 15:08 عصر
من چند بار کد کپی کردم نمیدونم چرا سایت با این کد مشکل داره میریزه به هم


برای تب ویجت ای دی زیر را بزار

TabWidget
android:id="@android:id/tabs"

hasan_esfahan
سه شنبه 19 مرداد 1395, 15:11 عصر
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >


<TabHost
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabHost3"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">


<LinearLayout
android:id="@+id/sadasdsa"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget>


<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">


<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>


<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>


</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>