제가 말하자면 카카오톡처럼 위에 메뉴판 구성을 하고
각각 메뉴별로 그 아래에 그리드뷰 형식으로 사진들을 넣으려고 하는데요.
탭레이아웃으로 메뉴를 구성하고 그리드뷰로 사진들을 넣을려고 하는데 저한테는 너무 어렵네요 ㅠㅠ
xml 파일은 이런식으로 작성을 했습니다.
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:numColumns="4"
></GridView>
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:numColumns="4"
></GridView>
</LinearLayout>
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></TabWidget>
</LinearLayout>
</TabHost>
근데 자바 파일을 못건들이겠어요......
package com.example.project;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("Homme");
TabHost tabhost = (TabHost)findViewById(R.id.linearLayout1);
tabhost.setup();
TabHost.TabSpec spec;
spec = tabhost.newTabSpec("GridView1");
spec.setContent(R.id.tab1);
spec.setIndicator("street");
tabhost.addTab(spec);
spec = tabhost.newTabSpec("GridView2");
spec.setContent(R.id.tab2);
spec.setIndicator("Brand");
tabhost.addTab(spec);
tabhost.setCurrentTab(0);
}
}
여기서 분명 잘못된 부분이 꽤 되는거 같은데 찾아내지도 못하겠고요 ㅠㅠㅠㅠ
누구든 도와주시면 감사해요 ㅠㅠㅠㅠㅠㅠ