탭을 만든 java파일이 있습니다.
package android.ch6;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;
public class ISEEActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabhost = (TabHost)findViewById(R.id.tabhost);
tabhost.setup();
TabHost.TabSpec spec;
spec = tabhost.newTabSpec("배경");
spec.setContent(R.id.tab1);
spec.setIndicator("배경");
tabhost.addTab(spec);
spec = tabhost.newTabSpec("이름");
spec.setContent(R.id.tab2);
spec.setIndicator("이름");
tabhost.addTab(spec);
spec = tabhost.newTabSpec("주소");
spec.setContent(R.id.tab3);
spec.setIndicator("주소");
tabhost.addTab(spec);
spec = tabhost.newTabSpec("전화번호");
spec.setContent(R.id.tab4);
spec.setIndicator("전화번호");
tabhost.addTab(spec);
spec = tabhost.newTabSpec("결과");
spec.setContent(R.id.tab5);
spec.setIndicator("결과");
tabhost.addTab(spec);
tabhost.setCurrentTab(1);
}
그리드뷰 만드는 java파일은 이것입니다.
package android.ch6;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class BasicGridView extends Activity {
GridView gridview;
GridViewAdapter adapter;
int[] gridImage =
{R.drawable.bg1,
R.drawable.bg2,
R.drawable.bg3,
R.drawable.bg4,
R.drawable.bg5};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gridview = (GridView) findViewById(R.id.gridview);
adapter = new GridViewAdapter(this,gridImage);
gridview.setAdapter(adapter);
}
class GridViewAdapter extends BaseAdapter
{
private int[] object;
private Context context;
public GridViewAdapter(){
super();
}
public GridViewAdapter(Context context,int[] object){
super();
this.context = context;
this.object = object;
}
public Object getItem(int arg0){
return null;
}
public long getItemId(int arg0){
return 0;
}
public View getView(int position, View convertView, ViewGroup parent){
ImageView image = new ImageView(context);
image.setImageResource(object[position]);
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
image.setLayoutParams(new GridView.LayoutParams(70,70));
return image;
}
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
}
}
실행해보면 오류는 나지않지만 그리드뷰가 안나옵니다..
이것들을 따로만들지 말고 한개로 합쳐야 하나요 ㅠㅠ?
참고로 메인문은 간단히 해서 이렇게 됩니다.. 서로 어떻게 연결을 해야
탭에 그리드뷰가 나올수 있을까요 ..
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3" >
</GridView>
</LinearLayout>
딱봐도..getCount 0이네요.........