왼쪽의 그림과 같은 탭 부분에 오른쪽과 같이 여러줄 출력된 리스트뷰를 붙이고 싶습니다..
두개의 예제는 소화를 했으나.. 어떻게 합치는지 모르겠어요 ㅜ.ㅜ
소스 올립니다... 도와주세요..
[탭소스 java]
package my.app;
import android.app.TabActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TabHost;
public class HelloTab2 extends TabActivity {
TabHost mTabHost = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] aStrings = {"해장국","계란국"};//메뉴는 받아와야겠죠
ListView list = (ListView) findViewById(R.id.listview1);
list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, aStrings));
String[] bStrings = {"돈가스","오징어덮밥","떡볶이"};
ListView list2 = (ListView) findViewById(R.id.listview2);
list2.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, bStrings));
String[] cStrings = {"철판볶음밥","부대찌게"};
ListView list3 = (ListView) findViewById(R.id.listview3);
list3.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, cStrings));
mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("아침메뉴").setContent(R.id.listview1));
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("점심메뉴").setContent(R.id.listview2));
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("저녁메뉴").setContent(R.id.listview3));
mTabHost.setCurrentTab(0);
}
}
[탭소스 xml]
<?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">
<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">
<ListView
android:id="@+id/listview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ListView
android:id="@+id/listview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ListView
android:id="@+id/listview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
</TabHost>
[여러줄 리스트뷰 java]
package com.androidhuman.ListExample;
import java.util.ArrayList;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class ListExample extends ListActivity{ // ListActivity를 상속받습니다.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList m_orders = new ArrayList();
Person p1 = new Person("해장국", "16"); // 리스트에 추가할 객체입니다.
Person p2 = new Person("계란국", "12"); // 리스트에 추가할 객체입니다.
m_orders.add(p1); // 리스트에 객체를 추가합니다.
m_orders.add(p2); // 리스트에 객체를 추가합니다.
PersonAdapter m_adapter = new PersonAdapter(this, R.layout.row, m_orders); // 어댑터를 생성합니다.
setListAdapter(m_adapter); //
}
private class PersonAdapter extends ArrayAdapter {
private ArrayList items;
public PersonAdapter(Context context, int textViewResourceId, ArrayList items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
Person p = (Person)items.get(position);
if (p != null) {
TextView tt = (TextView) v.findViewById(R.id.toptext);
TextView bt = (TextView) v.findViewById(R.id.bottomtext);
TextView ct = (TextView) v.findViewById(R.id.bottomtext2);
TextView dt = (TextView) v.findViewById(R.id.bottomtext3);
TextView et = (TextView) v.findViewById(R.id.bottomtext4);
TextView ft = (TextView) v.findViewById(R.id.bottomtext5);
TextView gt = (TextView) v.findViewById(R.id.bottomtext6);
if (tt != null){
tt.setText(p.getName());
}
if (bt != null){
bt.setText("예상 판매량 : " + p.getNumber());
}
if(ct != null){
ct.setText("09:00~10:00 : ");
}
if(dt != null){
dt.setText("11:00~13:00 : ");
}
if(et != null){
et.setText("13:00~15:00 : ");
}
if(ft != null){
ft.setText("15:00~17:00 : ");
}
if(gt != null){
gt.setText("17:00~19:00 : ");
}
}
return v;
}
}
class Person {
private String Name;
private String Number;
public Person(String _Name, String _Number){
this.Name = _Name;
this.Number = _Number;
}
public String getName() {
return Name;
}
public String getNumber() {
return Number;
}
}
}
[여러줄 리스트뷰 xml 1]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="tets"/>
</LinearLayout>
[xml2]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dip" android:orientation="vertical">
<TextView
android:id="@+id/toptext"
android:layout_width="fill_parent"
android:gravity="center_vertical"
android:layout_height="wrap_content" android:textSize="20px"/>
<TextView
android:layout_width="fill_parent"
android:id="@+id/bottomtext"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="fill_parent"
android:id="@+id/bottomtext2"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="fill_parent"
android:id="@+id/bottomtext3"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="fill_parent"
android:id="@+id/bottomtext4"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="fill_parent"
android:id="@+id/bottomtext5"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="fill_parent"
android:id="@+id/bottomtext6"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_height="wrap_content"/>
</LinearLayout>
이렇게요ㅜㅜ