안드로이드 개발 질문/답변
(글 수 45,052)
상단의 탭이 좌우로 스크롤이 가능하더군요.
제가 만들고 있는 어플에서는 Tab 항목수가 1+n개 인데요.
일단 탭항목을 6개를 만들어 놓고
TabWidget을 weightSum="4" 로 적용시켜 돌려보니 아래처럼 결과값은
나오는데 좌우 스크롤이 안되더라구요 ㅜㅠ
상단의 탭을 좌우 스크롤 하는 방법이 있을까요?
2010.10.13 20:14:48
http://androidforums.com/application-development/146572-how-use-horizontalscrollview.html#post1349428
샘플은 있으나, 문제는 하단의탭을 눌렀을때 나오는 하단 컨텐츠 부분도 같이 이동이 되더군요.
해결방법 있으신분 조언좀..
2010.11.12 19:20:40
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/arrowright" android:layout_gravity="right"></ImageView>
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/arrowleft"></ImageView>
<HorizontalScrollView
android:id="@+id/imageViewHorizontalScroll"
android:background="#00FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:addStatesFromChildren="true">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FF383838"
android:minWidth="600px"/>
</HorizontalScrollView>
</FrameLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
</LinearLayout>
</TabHost>
2010.11.12 19:21:12
package com.kdt.m2m.activity.custom;
import java.util.ArrayList;
import android.R.layout;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Layout;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TabHost.OnTabChangeListener;
import com.kdt.m2m.R;
import com.kdt.m2m.data.model.KGlobal;
import com.kdt.m2m.utils.KM2MUtil;
import com.kdt.m2m.utils.KTab;
public class customFrame extends TabActivity implements OnTabChangeListener
{
Context context = this;
private TabHost tabHost;
/** Called when the activity is first created. */
ArrayList<String> a = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_frame);
tabHost = getTabHost();
int serviceCode = KGlobal.service_List.get(KGlobal.service_Position).getSERVICECODE();
a.clear();
KTab.create(this, tabHost, "customTotal" , "종합진단", new Intent(this,customTotal.class), R.drawable.icon_total);
KTab.create(this, tabHost, "customEcoJisu" , "에코지수", new Intent(this,customEcoJisu.class), R.drawable.icon_eco);
KTab.create(this, tabHost, "customMeas" , "계측정보", new Intent(this,customMeas.class), R.drawable.icon_meas);
a.add("customTotal");
a.add("customEcoJisu");
a.add("customMeas");
if(KM2MUtil.SERVICE_IKEN== serviceCode)
{
KTab.create(this, tabHost, "customDB" , "DB증강현실", new Intent(this,customDB.class), R.drawable.icon_db);
a.add("customDB");
}
KTab.create(this, tabHost, "customAlarm" , "경보현황", new Intent(this,customAlarm.class), R.drawable.icon_alarm);
a.add("customAlarm");
if(KM2MUtil.SERVICE_IKEN== serviceCode)
{
KTab.create(this, tabHost, "customReport" , "보고서", new Intent(this,customReport.class), R.drawable.icon_report);
a.add("customReport");
}
KTab.create(this, tabHost, "customInfo" , "고객정보", new Intent(this,customInfo.class), R.drawable.icon_custominfo);
a.add("customInfo");
for(int i =0;i<tabHost.getTabWidget().getChildCount();i++){
tabHost.getTabWidget().getChildAt(i).setLayoutParams(
new LinearLayout.LayoutParams(120, 108));
if(a.get(i).equals("customDB")){
final int i_f = i;
tabHost.getTabWidget().getChildAt(i).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
KGlobal.showToast(context, "aa");
tabHost.setCurrentTabByTag("customDB");
}
});
}
}
setTitle(KGlobal.custUseName+" 고객님 환영합니다.");
int idx = getIntent().getExtras().getInt("tabIndex") ;
tabHost.setOnTabChangedListener(this);
tabHost.setCurrentTab(idx);
onTabChanged("customEcoJisu");
}
public void onTabChanged(String tabId) {
for(int i =0;i<tabHost.getTabWidget().getChildCount();i++){
tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.bg_tab_nomal);
}
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundResource(R.drawable.bg_tab_on);
// Log.d("Tab Changed Event"," Click Tab Id"+tabId);
// if(tabId.equals("tab_custom_jaga")){
// Log.d("Tab Id : ",tabId);
// ((customJaga)getCurrentActivity()).sync();
// }else if(tabId.equals("tab_custom_meas")){
// Log.d("Tab Id : ",tabId);
// ((customMeas)getCurrentActivity()).sync();
// }else if(tabId.equals("tab_custom_alarm")){
// Log.d("Tab Id : ",tabId);
// ((customAlarm)getCurrentActivity()).syncSpinnerItem(KGlobal.package_Position);
// }else if(tabId.equals("tab_custom_info")){
// Log.d("Tab Id : ",tabId);
// ((customInfo)getCurrentActivity()).syncComponentData();
//// }else if(tabId.equals("tab_custom_dbar")){
//// Log.d("Tab Id : ",tabId);
//// ((customDBAR)getCurrentActivity()).syncSpinnerItem(KGlobal.package_Position);
// }else if(tabId.equals("tab_custom_qr")){
// Log.d("Tab Id : ",tabId);
//// ((customQR)getCurrentActivity()).syncComponentData();
// }
}
}





